pytr-org / pytr

Use TradeRepublic in terminal and mass download all documents
https://pypi.org/project/pytr/
MIT License
387 stars 70 forks source link

pytr download of docs fails if last_days option is provided #79

Closed BjBe82 closed 3 months ago

BjBe82 commented 3 months ago

Description of the bug Running "pytr dl_docs -n +49.... -p ... "" --last_days 10" reports an error, see below. If no last_days are provided, everything works fine.

I think the solution is basically the fix in #74 related to Unixtimestamps (see comments).

To Reproduce Run "pytr dl_docs -n +49.... -p ... "" --last_days 10"

Expected behavior No error.

Error log

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "E:\Trade Republic\pytr\.venv\Scripts\pytr.exe\__main__.py", line 7, in <module>
  File "E:\Trade Republic\pytr\pytr\main.py", line 211, in main
    asyncio.get_event_loop().run_until_complete(dl.dl_loop())
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2544.0_x64__qbz5n2kfra8p0\Lib\asyncio\base_events.py", line 654, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "E:\Trade Republic\pytr\pytr\dl.py", line 80, in dl_loop
    await self.tl.get_next_timeline_activity_log(response, max_age_timestamp=self.since_timestamp)
  File "E:\Trade Republic\pytr\pytr\utils.py", line 332, in get_next_timeline_activity_log
    await self._get_timeline_details(5, max_age_timestamp=max_age_timestamp)
  File "E:\Trade Republic\pytr\pytr\utils.py", line 356, in _get_timeline_details
    if max_age_timestamp != 0 and event['timestamp'] > max_age_timestamp:
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: '>' not supported between instances of 'str' and 'float'

Environment

BjBe82 commented 3 months ago

Created a PR #80

Katzmann1983 commented 3 months ago

Fixed in master now. Thanks for your PR

fft1010 commented 3 months ago

Hi @Katzmann1983, I still get the version number 0.1.9 (got the version on 14:03 :-) ) And this version still does not download the "Abrechnung" since 7th june... If I am too early just tell me.

see

screen-2024-07-02-14-03-14

anything I am doing wrong? thanks Jeurgen

BjBe82 commented 3 months ago

Hi @Katzmann1983, I still get the version number 0.1.9 (got the version on 14:03 :-) ) And this version still does not download the "Abrechnung" since 7th june... If I am too early just tell me.

see

screen-2024-07-02-14-03-14

anything I am doing wrong? thanks Jeurgen

Can you please check if the missing files are in "/Dokumente" now. At least for Dividends, this is the case for me now, since the title of the document in the timeline changed from "Abrechnung" to "Dokumente" after a certain date.

fft1010 commented 3 months ago

Hi I think I have the wrong version.

I do a

pip3 uninstall pytr and than pip3 install pytr

Than the file date of /Library/Frameworks/Python.framework/Versions/3.12/bin/pytr changes to the actual date, but pytr -V still says

0.1.9
17:09:53 pytr is up to date

I than moved the download subdir, to get a new subdir and run

pytr dl_docs docs

And than no, there is no "Dokumente" directory below "docs". But I also think, that "Now" (2024-07-02 17:14) TR has problems I get:

17:13:59 Received error message: '2005 E {"errors":[{"errorCode":"UNKNOWN_ERROR","errorField":null,"errorMessage":"The timeout period of 15000ms has been exceeded while executing GET /api/v1/timeline/fd57c137-e19d-4f3f-9bba-a6cb34cee1eb for server neon-backend-timeline.default.svc.cluster.local:80","meta":{"source":"MAPPER"}}]}'
17:13:59 ('2005', {'type': 'timelineDetail', 'id': 'fd57c137-e19d-4f3f-9bba-a6cb34cee1eb'}, {'errors': [{'errorCode': 'UNKNOWN_ERROR', 'errorField': None, 'errorMessage': 'The timeout period of 15000ms has been exceeded while executing GET /api/v1/timeline/fd57c137-e19d-4f3f-9bba-a6cb34cee1eb for server neon-backend-timeline.default.svc.cluster.local:80', 'meta': {'source': 'MAPPER'}}]})

But "many" of the files are downloaded, but the ones after 7th june are still missing. (Except "Zinsen" from 1st July are in the "Abrechnung" subdir)

this is

screen-2024-07-02-17-18-33

how my docs dir looks like.

thanks Juergen

fft1010 commented 3 months ago

Hi, the installation only works with a git clone

git clone https://github.com/pytr-org/pytr

and not as described in the documentation. I have no clue why. Sorry if this is a newbie thing. I now see changed document names, and I get a "Documentation" subdir, although most of the docs are in "Abrechnung". Only one doc made it into "Documentation", I donno why.

Thanks for all the effords, but I would definitely change the version number, it still shows 0.1.9 which is the same as the one that does not work.

thanks Juergen

BjBe82 commented 3 months ago

The pipx install pytr will pull the package from: https://pypi.org/project/pytr/ which is the version from "29. Okt. 2023". So for the:

commands to work, a new release needs to be published there. In the meantime, it might be beneficial to highlight in the README.md that:

git clone https://github.com/marzzzello/pytr.git
cd pytr
pip install .

should be used in between releases. I think this would also benefit error reports which are already fixed in master, but the user still test with a depreciated version from the python registry.

G-Ultimatee commented 3 months ago

EDIT: With the latest update (03.07.2024) it works again like a charm. THANKS

Hope It's fine to post here. If I use the most recent version from git clone https://github.com/marzzzello/pytr.git and do a pip install . then I still can't use the last_days command. If I say pytr dl_docs --last_days 10 C:\Users.... it downloads all documents instead of the ones of last 10 days.

However in the previous version I received an error with --last_days. Now there is no error message but not considering the --last_days command.

EDIT: Sorry for inconvenience. I realised that it is indeed only downloading the last_days period as it should. I was just surprised and not sure because the command dialog shows me way more downloads like so:

... 20:46:39 1049/1130: Amazon -- Sparplan ausgeführt 20:46:39 1050/1130: Waste Management -- Sparplan ausgeführt ....

So it runs through all the 1130 lines line by line. I think in previous (working) version it only showed less lines (only from --last_days period).