Git Product home page Git Product logo

pytr's Introduction

GitHub tag (with filter) PyPI build and publish PyPI - Version

pytr: Use TradeRepublic in terminal

This is a library for the private API of the Trade Republic online brokerage. I am not affiliated with Trade Republic Bank GmbH.

Installation

Make sure Python and a Python package manager like pip or pipx (recommended) is installed.

Install release from PyPI with pipx install pytr

Or install from git repo like so:

pipx install git+https://github.com/marzzzello/pytr

Update

pipx upgrade pytr
# or
pipx upgrade-all

Usage

$ pytr help
usage: pytr [-h] [-v {warning,info,debug}] [-V]
            {help,login,dl_docs,portfolio,details,get_price_alarms,set_price_alarms,export_transactions,completion}
            ...

Use "pytr command_name --help" to get detailed help to a specific command

Commands:
  {help,login,dl_docs,portfolio,details,get_price_alarms,set_price_alarms,export_transactions,completion}
                         Desired action to perform
    help                 Print this help message
    login                Check if credentials file exists. If not create it
                         and ask for input. Try to login. Ask for device reset
                         if needed
    dl_docs              Download all pdf documents from the timeline and sort
                         them into folders. Also export account transactions
                         (account_transactions.csv) and JSON files with all
                         events (events_with_documents.json and
                         other_events.json
    portfolio            Show current portfolio
    details              Get details for an ISIN
    get_price_alarms     Get overview of current price alarms
    set_price_alarms     Set price alarms based on diff from current price
    export_transactions  Create a CSV with the deposits and removals ready for
                         importing into Portfolio Performance
    completion           Print shell tab completion

Options:
  -h, --help             show this help message and exit
  -v {warning,info,debug}, --verbosity {warning,info,debug}
                         Set verbosity level (default: info)
  -V, --version          Print version information and quit

Authentication

There are two authentication methods:

  • Web login (default)
  • App login

Web login is the newer method that uses the same login method as app.traderepublic.com, meaning you receive a token in the TradeRepublic app or via SMS.

App login is the older method that uses the same login method as the TradeRepublic app. First you need to perform a device reset - a private key will be generated that pins your "device". The private key is saved to your keyfile. This procedure will log you out from your mobile device.

$ pytr login
$ # or
$ pytr login --phone_no +49123456789 --pin 1234

If no arguments are supplied pytr will look for them in the file ~/.pytr/credentials (the first line must contain the phone number, the second line the pin). If the file doesn't exist pytr will ask for for the phone number and pin.

pytr's People

Contributors

akaame avatar cgoncalves avatar ivoihlemann avatar marzzzello avatar miry avatar nborrmann avatar parodev93 avatar peteh avatar ptrstn avatar sepidre avatar tilidev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pytr's Issues

Login error, multiple errors

When login:

20:58:24 Credentials not saved
Traceback (most recent call last):
  File "C:\Users\psc\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pytr\api.py", line 188, in inititate_weblogin
    self._process_id = j['processId']
KeyError: 'processId'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2544.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2544.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\psc\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\Scripts\pytr.exe\__main__.py", line 7, in <module>
  File "C:\Users\psc\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pytr\main.py", line 121, in main
    login(phone_no=args.phone_no, pin=args.pin, web=weblogin)
  File "C:\Users\psc\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pytr\account.py", line 70, in login
    countdown = tr.inititate_weblogin()
  File "C:\Users\psc\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pytr\api.py", line 192, in inititate_weblogin
    raise ValueError(str(err))
ValueError: [{'errorCode': 'NUMBER_INVALID', 'errorMessage': 'phoneNumber', 'meta': None}]

Windows 10, see simliar errors in reddit posts for example

ssl.SSLCertVerificationError

Hi - also thanks in advance. Unbelievable that it is so hard for them to make that data accessible.

I ran into the following problem. Seems like there's no validation of SSL keys happening in Python?
Not sure what to do -- and happy to learn how to navigate this issue.

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.9/bin/pytr", line 8, in <module>
    sys.exit(main())
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pytr/main.py", line 152, in main
    Portfolio(login()).get()
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pytr/portfolio.py", line 73, in get
    asyncio.get_event_loop().run_until_complete(self.portfolio_loop())
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
    return future.result()
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pytr/portfolio.py", line 11, in portfolio_loop
    await self.tr.portfolio()
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pytr/api.py", line 279, in portfolio
    return await self.subscribe({'type': 'portfolio'})
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pytr/api.py", line 188, in subscribe
    ws = await self._get_ws()
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pytr/api.py", line 168, in _get_ws
    self._ws = await websockets.connect('wss://api.traderepublic.com')
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/websockets/legacy/client.py", line 622, in __await_impl__
    transport, protocol = await self._create_connection()
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/base_events.py", line 1081, in create_connection
    transport, protocol = await self._create_connection_transport(
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/base_events.py", line 1111, in _create_connection_transport
    await waiter
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/sslproto.py", line 528, in data_received
    ssldata, appdata = self._sslpipe.feed_ssldata(data)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/sslproto.py", line 188, in feed_ssldata
    self._sslobj.do_handshake()
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/ssl.py", line 944, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)```

Saveback documents are not downloaded

Description of the bug
The documents related to the saveback are not downloaded.

I use the saveback on a ETF savings plan. While the usual monthly transaction document is downloaded to "Sparplan/Abrechnung Ausführung" the transaction document for the separate investment of the saveback is missing. In addition in the transaction details in the TR-App there is an additional document "Kosteninformation" every month and with the first transaction of the saveback there is the "Activation" document.

To Reproduce
Steps to reproduce the behavior:

Ran the command pytr dl_docs ./

Expected behavior
All documents related to the saveback should be downloaded.

Environment

  • OS: MacOS 13.6.7
  • pytr version: 0.1.9

Connection Error on dl_docs

Hi, when trying to download documents I get connection error. Worked fine in the past...

Error log

pytr dl_docs .      
23:19:02 Found credentials file
23:19:02 Phone: +49160********, PIN: ****
23:19:03 Web session resumed
23:19:03 Logged in
23:19:03 Awaiting #1  timeline
23:19:03 Connecting to websocket ...
Traceback (most recent call last):
  File "/usr/local/bin/pytr", line 10, in <module>
    sys.exit(main())
  File "/Library/Python/3.7/site-packages/pytr/main.py", line 152, in main
    asyncio.get_event_loop().run_until_complete(dl.dl_loop())
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/asyncio/base_events.py", line 584, in run_until_complete
    return future.result()
  File "/Library/Python/3.7/site-packages/pytr/dl.py", line 34, in dl_loop
    await self.tl.get_next_timeline(max_age_timestamp=self.since_timestamp)
  File "/Library/Python/3.7/site-packages/pytr/utils.py", line 100, in get_next_timeline
    await self.tr.timeline()
  File "/Library/Python/3.7/site-packages/pytr/api.py", line 438, in timeline
    return await self.subscribe({'type': 'timeline', 'after': after})
  File "/Library/Python/3.7/site-packages/pytr/api.py", line 288, in subscribe
    ws = await self._get_ws()
  File "/Library/Python/3.7/site-packages/pytr/api.py", line 274, in _get_ws
    raise ValueError(f'Connection Error: {response}')
ValueError: Connection Error: failed 31

Environment

  • OS: Mac OS 14.2.1 (23C71)
  • pytr version: (pytr: error: unrecognized arguments: -V)

Not all Files are downloaded Correctly

18:22:08 Received all details

18:22:08 Waiting for downloads to complete..

Traceback (most recent call last):

File "C:\Users\name\miniconda3\lib\runpy.py", line 197, in _run_module_as_main

return _run_code(code, main_globals, None,

File "C:\Users\name\miniconda3\lib\runpy.py", line 87, in _run_code

exec(code, run_globals)

File "C:\Users\name\miniconda3\Scripts\pytr.exe\__main__.py", line 7, in <module>

File "C:\Users\name\miniconda3\lib\site-packages\pytr\main.py", line 152, in main

asyncio.get_event_loop().run_until_complete(dl.dl_loop())

File "C:\Users\name\miniconda3\lib\asyncio\base_events.py", line 642, in run_until_complete

return future.result()

File "C:\Users\name\miniconda3\lib\site-packages\pytr\dl.py", line 46, in dl_loop

await self.tl.timelineDetail(response, self, max_age_timestamp=self.since_timestamp)

File "C:\Users\name\miniconda3\lib\site-packages\pytr\utils.py", line 227, in timelineDetail

dl.work_responses()

File "C:\Users\name\miniconda3\lib\site-packages\pytr\dl.py", line 130, in work_responses

with open(future.filepath, 'wb') as f:

FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\name\\Documents\\TR-New\\Terms of service - credit cards and wallets \\2021-08-05 2101 Dokumente akzeptiert.pdf'

Connection error while downloading documents

Description of the bug
While trying to download the documents with dl_docs the code stops in the middle

To Reproduce
Hard to describe, as it is probably user dependent, my guess would be, that the pytr package might not support options trading and it canceled at the first of these documents. Maybe a better error handling strategy would be to to skip these documents and then name all skipped documents at the end of code execution

Error log

(base) C:\Users\49176\Documents\trade_republic>pytr dl_docs .
17:27:53 Found credentials file
17:27:53 Phone: +49176********, PIN: ****
17:27:54 Web session resumed
17:27:54 Logged in
17:27:54 Found 98 lines in history file
17:27:54 Awaiting #1  timeline
17:27:54 Connecting to websocket ...
17:27:54 Connected to websocket ...
17:27:54 Received #1  timeline, awaiting #2  timeline
17:27:55 Received #2  timeline, awaiting #3  timeline
17:27:55 Received #3  (last) timeline
17:27:55  1/65: Deine Unterlagen -- Sa. 30.10. um 21:41 Uhr (Europe/Berlin)
17:27:55  2/65: Basisinformationen -- Sa. 30.10. um 21:41 Uhr (Europe/Berlin)
17:27:55  3/65: Abschluss Q4/2021 -- Sa. 01.01. um 00:59 Uhr (Europe/Berlin)
17:27:55  4/65: Kauf Beyond Meat -- Mi. 05.01. um 20:59 Uhr (Europe/Berlin)
17:27:55  5/65: Core MSCI World USD (Acc) -- Sparplan
17:27:55  6/65: Core MSCI EM IMI USD (Acc) -- Sparplan
17:27:55  7/65: Kauf GoodYear -- Do. 03.03. um 14:22 Uhr (Europe/Berlin)
17:27:55  8/65: Kauf GoodYear -- Do. 03.03. um 15:44 Uhr (Europe/Berlin)
17:27:55  9/65: Kauf Global Clean Energy USD (Dist) -- Fr. 04.03. um 14:01 Uhr (Europe/Berlin)
17:27:55 10/65: Kauf BASF -- Do. 03.03. um 16:13 Uhr (Europe/Berlin)
17:27:55 11/65: Kauf ITM Power -- Fr. 04.03. um 14:34 Uhr (Europe/Berlin)
17:27:55 12/65: Kauf ITM Power -- Fr. 04.03. um 14:34 Uhr (Europe/Berlin)
17:27:55 13/65: Kauf Krones -- Fr. 04.03. um 14:38 Uhr (Europe/Berlin)
17:27:55 14/65: S&P Global Luxury EUR (Acc) -- Sparplan
17:27:55 15/65: Kauf BASF -- Fr. 04.03. um 14:41 Uhr (Europe/Berlin)
17:27:55 16/65: Kauf Call @41.00 € Bayer AG Optionsschein -- Di. 08.03. um 14:12 Uhr (Europe/Berlin)
17:27:55 17/65: Call @41.00 € Bayer AG Optionsschein -- Mi. 09.03. um 01:00 Uhr (Europe/Berlin)
17:27:55 18/65: Kauf Long @4.49 € ITM Power Open End Turbo -- Mi. 09.03. um 08:30 Uhr (Europe/Berlin)
17:27:55 19/65: Kauf Long @50.32 € BASF Open End Turbo -- Mi. 09.03. um 13:35 Uhr (Europe/Berlin)
17:27:55 20/65: Kauf Call @60.00 € BASF Optionsschein -- Mi. 09.03. um 15:13 Uhr (Europe/Berlin)
17:27:55 21/65: Call @60.00 € BASF Optionsschein -- Do. 10.03. um 00:22 Uhr (Europe/Berlin)
17:27:55 22/65: Kauf Core MSCI World USD (Acc) -- Do. 10.03. um 11:20 Uhr (Europe/Berlin)
17:27:55 23/65: Kauf Global Clean Energy USD (Dist) -- Do. 10.03. um 09:07 Uhr (Europe/Berlin)
17:27:55 24/65: Kauf Core MSCI EM IMI USD (Acc) -- Do. 10.03. um 11:24 Uhr (Europe/Berlin)
17:27:55 25/65: Edge Europe Value EUR (Acc) -- Sparplan
17:27:55 26/65: Kauf Upstart Holdings -- Do. 10.03. um 13:15 Uhr (Europe/Berlin)
17:27:55 27/65: Kauf Daimler Truck -- Do. 10.03. um 20:14 Uhr (Europe/Berlin)
17:27:55 28/65: Kauf Daimler Truck -- Do. 10.03. um 20:14 Uhr (Europe/Berlin)
17:27:55 29/65: Kauf Global Clean Energy USD (Dist) -- Do. 10.03. um 14:46 Uhr (Europe/Berlin)
17:27:55 30/65: Core MSCI EM IMI USD (Acc) -- Sparplan
17:27:56 31/65: Kauf BASF -- Do. 10.03. um 20:15 Uhr (Europe/Berlin)
17:27:56 32/65: Kauf Core MSCI World USD (Acc) -- Do. 10.03. um 20:55 Uhr (Europe/Berlin)
17:27:56 33/65: Kauf BASF -- Do. 10.03. um 20:16 Uhr (Europe/Berlin)
17:27:56 34/65: Kauf Core MSCI World USD (Acc) -- Do. 10.03. um 20:54 Uhr (Europe/Berlin)
17:27:56 35/65: Kauf Core MSCI World USD (Acc) -- Do. 10.03. um 20:55 Uhr (Europe/Berlin)
17:27:56 36/65: Kauf Shopify -- Do. 10.03. um 20:59 Uhr (Europe/Berlin)
17:27:56 37/65: Verkauf Long @4.49 € ITM Power Open End Turbo -- Fr. 11.03. um 00:12 Uhr (Europe/Berlin)
17:27:56 38/65: Kauf Shopify -- Fr. 11.03. um 11:10 Uhr (Europe/Berlin)
17:27:56 39/65: Kauf Shopify -- Fr. 11.03. um 12:52 Uhr (Europe/Berlin)
17:27:56 40/64: Verkauf Long @50.32 € BASF Open End Turbo -- Fr. 11.03. um 12:29 Uhr (Europe/Berlin)
17:27:56 41/64: Kauf Shopify -- Fr. 11.03. um 13:19 Uhr (Europe/Berlin)
17:27:56 42/64: Kauf Shopify -- Fr. 11.03. um 13:19 Uhr (Europe/Berlin)
17:27:56 43/64: Verkauf Call @41.00 € Bayer AG Optionsschein -- Fr. 11.03. um 15:38 Uhr (Europe/Berlin)
17:27:56 44/64: Kauf Edge Europe Value EUR (Acc) -- Fr. 11.03. um 15:48 Uhr (Europe/Berlin)
17:27:56 45/64: Kauf Edge Europe Value EUR (Acc) -- Fr. 11.03. um 15:47 Uhr (Europe/Berlin)
17:27:56 46/64: Verkauf Shopify -- Fr. 11.03. um 16:56 Uhr (Europe/Berlin)
17:27:56 47/64: Global Clean Energy USD (Dist) -- Sparplan
17:27:56 48/64: Verkauf Shopify -- Fr. 11.03. um 19:11 Uhr (Europe/Berlin)
17:27:56 49/64: Verkauf Shopify -- Fr. 11.03. um 19:12 Uhr (Europe/Berlin)
17:27:56 50/64: Kauf BASF -- Fr. 11.03. um 20:35 Uhr (Europe/Berlin)
17:27:56 51/64: Kauf Krones -- Fr. 11.03. um 20:35 Uhr (Europe/Berlin)
17:27:57 52/64: Dokumente akzeptiert -- Sa. 12.03. um 00:03 Uhr (Europe/Berlin)
17:27:57 53/64: Kauf Edge Europe Value EUR (Acc) -- Fr. 11.03. um 20:35 Uhr (Europe/Berlin)
17:27:57 54/64: Core STOXX Europe 600 EUR (Acc) -- Sparplan
17:27:57 55/64: Kauf Bitcoin -- Sa. 12.03. um 01:05 Uhr (Europe/Berlin)
17:27:57 56/64: FTSE EPRA Nareit Global EUR (Acc) -- Sparplan
17:27:57 57/64: MSCI World SRI EUR (Acc) -- Sparplan
17:27:57 58/64: Tilgung -- Mi. 16.03. um 01:26 Uhr (Europe/Berlin)
17:27:57 59/64: Kauf Covestro -- Di. 15.03. um 18:53 Uhr (Europe/Berlin)
17:27:57 60/64: Core MSCI World USD (Acc) -- Sparplan
17:27:57 61/64: Kauf Ares Capital -- Mi. 16.03. um 20:40 Uhr (Europe/Berlin)
17:27:57 62/64: Kauf Omega Healthcare Invs -- Fr. 18.03. um 14:18 Uhr (Europe/Berlin)
17:27:57 63/64: Verkauf Ares Capital -- Mi. 16.03. um 20:56 Uhr (Europe/Berlin)
17:27:57 64/64: Kauf Omega Healthcare Invs -- Fr. 18.03. um 14:39 Uhr (Europe/Berlin)
17:27:57 Received all details
17:27:57 Write deposit entries
17:27:57 Deposit creation finished!
17:27:57 Waiting for downloads to complete..
Traceback (most recent call last):
  File "C:\Users\49176\anaconda3\lib\site-packages\urllib3\connectionpool.py", line 699, in urlopen
    httplib_response = self._make_request(
  File "C:\Users\49176\anaconda3\lib\site-packages\urllib3\connectionpool.py", line 445, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "C:\Users\49176\anaconda3\lib\site-packages\urllib3\connectionpool.py", line 440, in _make_request
    httplib_response = conn.getresponse()
  File "C:\Users\49176\anaconda3\lib\http\client.py", line 1371, in getresponse
    response.begin()
  File "C:\Users\49176\anaconda3\lib\http\client.py", line 319, in begin
    version, status, reason = self._read_status()
  File "C:\Users\49176\anaconda3\lib\http\client.py", line 288, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\49176\anaconda3\lib\site-packages\requests\adapters.py", line 439, in send
    resp = conn.urlopen(
  File "C:\Users\49176\anaconda3\lib\site-packages\urllib3\connectionpool.py", line 755, in urlopen
    retries = retries.increment(
  File "C:\Users\49176\anaconda3\lib\site-packages\urllib3\util\retry.py", line 532, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "C:\Users\49176\anaconda3\lib\site-packages\urllib3\packages\six.py", line 769, in reraise
    raise value.with_traceback(tb)
  File "C:\Users\49176\anaconda3\lib\site-packages\urllib3\connectionpool.py", line 699, in urlopen
    httplib_response = self._make_request(
  File "C:\Users\49176\anaconda3\lib\site-packages\urllib3\connectionpool.py", line 445, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "C:\Users\49176\anaconda3\lib\site-packages\urllib3\connectionpool.py", line 440, in _make_request
    httplib_response = conn.getresponse()
  File "C:\Users\49176\anaconda3\lib\http\client.py", line 1371, in getresponse
    response.begin()
  File "C:\Users\49176\anaconda3\lib\http\client.py", line 319, in begin
    version, status, reason = self._read_status()
  File "C:\Users\49176\anaconda3\lib\http\client.py", line 288, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\49176\anaconda3\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\49176\anaconda3\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\49176\anaconda3\Scripts\pytr.exe\__main__.py", line 7, in <module>
  File "C:\Users\49176\anaconda3\lib\site-packages\pytr\main.py", line 157, in main
    asyncio.get_event_loop().run_until_complete(dl.dl_loop())
  File "C:\Users\49176\anaconda3\lib\asyncio\base_events.py", line 642, in run_until_complete
    return future.result()
  File "C:\Users\49176\anaconda3\lib\site-packages\pytr\dl.py", line 64, in dl_loop
    await self.tl.timelineDetail(response, self, max_age_timestamp=self.since_timestamp)
  File "C:\Users\49176\anaconda3\lib\site-packages\pytr\utils.py", line 371, in timelineDetail
    dl.work_responses()
  File "C:\Users\49176\anaconda3\lib\site-packages\pytr\dl.py", line 149, in work_responses
    r = future.result()
  File "C:\Users\49176\anaconda3\lib\concurrent\futures\_base.py", line 438, in result
    return self.__get_result()
  File "C:\Users\49176\anaconda3\lib\concurrent\futures\_base.py", line 390, in __get_result
    raise self._exception
  File "C:\Users\49176\anaconda3\lib\concurrent\futures\thread.py", line 52, in run
    result = self.fn(*self.args, **self.kwargs)
  File "C:\Users\49176\anaconda3\lib\site-packages\requests\sessions.py", line 542, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\Users\49176\anaconda3\lib\site-packages\requests\sessions.py", line 655, in send
    r = adapter.send(request, **kwargs)
  File "C:\Users\49176\anaconda3\lib\site-packages\requests\adapters.py", line 498, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

Maybe one way to solve this is if you could tell me one line of code, where I could insert a print, to know after which iteration the code stops.
Connection during code execution was always good, so I can´t imagine that to be the problem.

Thank you for your help and the very promising tool!

pytr dl_docs is throwing error and cannot complete

I tried running pytr today again to download my latest documents but I repeatedly get the following error message:

Received error message: '27 E {"errors":[{"errorCode":"UNKNOWN_ERROR","errorField":null,"errorMessage":"Unknown error","meta":{"source":"PLATFORM"}}]}'
Traceback (most recent call last):
  File "/home/alex/.local/bin/pytr", line 8, in <module>
    sys.exit(main())
  File "/home/alex/.local/lib/python3.8/site-packages/pytr/main.py", line 135, in main
    asyncio.get_event_loop().run_until_complete(dl.dl_loop())
  File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "/home/alex/.local/lib/python3.8/site-packages/pytr/dl.py", line 28, in dl_loop
    _subscription_id, subscription, response = await self.tr.recv()
  File "/home/alex/.local/lib/python3.8/site-packages/pytr/api.py", line 246, in recv
    raise TradeRepublicError(subscription_id, subscription, payload)
pytr.api.TradeRepublicError: ('27', {'type': 'timelineDetail', 'id': '97ab309c-3101-45da-98f7-36d92172e041'}, {'errors': [{'errorCode': 'UNKNOWN_ERROR', 'errorField': None, 'errorMessage': 'Unknown error', 'meta': {'source': 'PLATFORM'}}]})

pytr downloading docs

Hello there,

I am using pytr and it worked well, but now I get an error message running pytr dl_docs 'Path'. I attached the error message.
I hope you can help me, because pytr is really useful.
error_message.txt

With kind regards, CodingMaster3000

'RequestCookieJar' object has no attribute 'load'

Description of the bug
After upgrading to 0.1.0 weblogin doesn't work anymore.

To Reproduce

  1. Go to 'terminal'
  2. Ran the command pytr login or pytr dl_docs .
  3. Do 'Enter phone number and pin when asked to'
  4. See error

Expected behavior
Pytr performs login and downloads documents

Error log

Traceback (most recent call last):
  File "C:\Users\xxx\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\Scripts\pytr-script.py", line 33, in <module>
    sys.exit(load_entry_point('pytr==0.1.0', 'console_scripts', 'pytr')())
  File "C:\Users\xxx\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pytr\main.py", line 143, in main
    login(phone_no=args.phone_no, pin=args.pin, web=weblogin)
  File "C:\Users\xxx\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pytr\account.py", line 66, in login
    if tr.resume_websession():
  File "C:\Users\xxx\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pytr\api.py", line 226, in resume_websession
    self._websession.cookies.load(ignore_discard=True, ignore_expires=True)
AttributeError: 'RequestsCookieJar' object has no attribute 'load'

Environment

  • OS: Windows 10
  • pytr version: 0.1.0

Additional context
0.0.18 worked before. Anything I did was updating pytr by calling pip install --upgrade pytr

Phone No and Pin arguments are ignored when credentials file exists

Description of the bug
When running pytr with -n/--phone_no and -p/--pin arguments and the credential file exists, those arguments will be ignored and the values in the credentials file will be used.
This is an issue, as the user does not receive any info about the arguments not being used and he has to delete the credentials file manually if login data changes (or was stored with wrong values).

To Reproduce
Steps to reproduce the behavior:

  1. Login with pytr
  2. Try to login with different credentials with specific arguments
  3. Login uses old credentials (even if they are wrong)

Expected behavior
Two options:

  1. always prefer arguments
  2. print that credentials file exists in ~/.pytr/credentials and offer an option to remove cached credentials in the CLI

Environment

  • OS: Mac
  • Version: 0.0.8

Unkown_Error on download documents

Hi,
recently i face the following error situation during the download of documents

pytr dl_docs --last_days 60 "C:\docs_downloaded"

21:31:15 Received error message: '1 E {"errors":[{"errorCode":"UNKNOWN_ERROR","errorField":null,"errorMessage":"Unknown error","meta":{"source":"PLATFORM"}}]}'
21:31:15 ('1', {'type': 'timeline', 'after': None}, {'errors': [{'errorCode': 'UNKNOWN_ERROR', 'errorField': None, 'errorMessage': 'Unknown error', 'meta': {'source': 'PLATFORM'}}]})
Traceback (most recent call last):
  File "c:\python38\lib\runpy.py", line 193, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\python38\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Python38\Scripts\pytr.exe\__main__.py", line 7, in <module>
  File "c:\python38\lib\site-packages\pytr\main.py", line 206, in main
    asyncio.get_event_loop().run_until_complete(dl.dl_loop())
  File "c:\python38\lib\asyncio\base_events.py", line 612, in run_until_complete
    return future.result()
  File "c:\python38\lib\site-packages\pytr\dl.py", line 67, in dl_loop
    if subscription['type'] == 'timeline':
UnboundLocalError: local variable 'subscription' referenced before assignment

login is successfully and querying the portfolio is working. Maybe they changed sth on their api. How can this be solved?

BG.

If multiple documents of the same type exist with the same date only one is downloaded

Description of the bug
I have several "Wertpapierübertrag" documents in my account that are identical in their date, title and subtitle (wherefrom the time is extracted). This is nothing unusual if you have transferred multiple different stocks from another broker to Trade Republic.
Subsequently the destination file paths that are created from these data by pytr are identical and thus only one file will be downloaded whilst the others are skipped.

To Reproduce
Steps to reproduce the behavior:

  1. Ran the command pytr dl_docs .
  2. Noticed that the number of downloaded document did not match the expected number of documents

Expected behavior
All files should be downloaded.
E.g. by adding a number if the file already exists.
Alternatively you could extend the --format FORMAT_STRING argument and provide id or body as variables.
This should be sufficient to create unique file names, e.g.:
--format "{iso_date}{time} {title}{doc_num} - {id}"

Error log

File ... already in queue. Skipping...

Environment

  • OS: MacOS
  • pytr version: 0.1.2

Additional context
Unfortunately these documents do not have a doc_num.

Error messages with dl_docs

Hi! First of all, thanks for all the work you put into this project and for sharing it here! High appreciated!

When I saw you updated it with a fix for the dl_docs problems, I went right ahead and downloaded everything from my TR-Acc. I downloaded a total of 100s of documents and while scrolling through the lines to see if everything worked smoothy, I noticed some "error-line", like such (maybe like 15 or so in total out of 100s of downloads):

13:41:17 2XX/9XX: Kauf StockA -- Di. 18.06. um 16:43 Uhr (Europe/Berlin) Received error message: '546 E {"errors":[{"errorCode":"BAD_REQUEST","errorField":null,"errorMessage":"Bad Request","meta":{"source":"PLATFORM"}}]}' 13:41:17 ('546', {'type': 'timelineDetail', 'id': '8g56243-6casd-1fff-22b8-034ed40e4d1c'}, {'errors': [{'errorCode': 'BAD_REQUEST', 'errorField': None, 'errorMessage': 'Bad Request', 'meta': {'source': 'PLATFORM'}}]})

I reran the command several times and the errors showed up in exactly the same lines every time.

Any idea what the problem might be?
Just wanted to share it also to contribute as best as I can here by at least reporting what I found.

Cheers!

last_days command seems to have no effect

Since I'm always getting a "BAD_REQUEST" error from the platform when executing dl_docs, I tried to limit the download to the last 5 days by using:

pytr dl_docs --last_days 5 .

This seems to have no effect for me. The download still starts at 01.06., which is where the first document was placed in my account.

EDIT: btw: the BAD_REQUEST seems to stem from the entry to verify your bank-account, so maybe it could be implemented to be skipped at the download

pytr portfolio stuck after connected to websocket

Description of the bug
When I want to use the portfolio command, the code gets stuck after connecting to the websocket. No matter how long I keep it running nothing happens. That's how far it gets:

pytr portfolio
22:41:56 Found credentials file
22:41:56 Phone: +4917********, PIN: ****
22:41:56 Web session resumed
22:41:56 Logged in
22:41:56 Connecting to websocket ...
22:41:56 Connected to websocket ...

Environment

  • OS: MacOS Sonoma 14.4.1
  • pytr version: 0.1.9

Any help is appreciated.

Crypto gets timeout

Hi together.

I bought the first time crypto (Ethereum) and at the next run, my script crashed with a timeout. It always gets a timeout if I try: tr.ticker("XF000ETH0019")

It seems like the ticker doesn't get crypto ticker. Does anybody have an idea how to solve this problem?

Cheers

Support for Visa Card transactions

Trade Republic now has a Debit Visa Card available which spendings are taken out from the Cash account directly.
However, pytr (as of V0.1.9) does not include this entries in the generated account_transactions.csv file yet.
In addition to the actual spending additional round-up values might be added if the account holder configured it.
Therefore, when importing this file into tools like Portfolio Performance the reported Cash amount is off.

Please adapt the script to also produce these entries.

Problems with dl_docs, installing problem?

Hi all,

I think I am doing something fundamental wrong. Maybe anyone can help. Just installed via pip the new version. logged successfully in and tried to dl_docs path

Command used:
pytr dl_docs PATH

Awaiting #1  timeline
Received #1  timeline, awaiting #2  timeline
Received #2  timeline, awaiting #3  timeline
Received #3  timeline, awaiting #4  timeline
Received #4  timeline, awaiting #5  timeline
Received #5  timeline, awaiting #6  timeline
Received #6  timeline, awaiting #7  timeline
Received #7  (last) timeline
1/209:   -- Fr. 18.12. um 12:19 Uhr (Europe/Berlin) -- istSparplan: False
2/209: Steuerabrechnung -- Sa. 19.12. um 01:04 Uhr (Europe/Berlin) -- istSparplan: False
3/209: Kauf Taat Lifestyle+Wellness -- Fr. 18.12. um 08:19 Uhr (Europe/Berlin) -- istSparplan: False
4/209: Verkauf Long @71.77 € Zalando Open End Turbo -- Fr. 18.12. um 19:23 Uhr (Europe/Berlin) -- istSparplan: False
5/209: Verkauf Long @71.80 € Zalando Open End Turbo -- Mo. 21.12. um 08:14 Uhr (Europe/Berlin) -- istSparplan: False
6/209:   -- Do. 05.11. um 10:32 Uhr (Europe/Berlin) -- istSparplan: False
7/209: Basisinformationen -- Do. 05.11. um 10:32 Uhr (Europe/Berlin) -- istSparplan: False
8/209:   -- Do. 05.11. um 10:32 Uhr (Europe/Berlin) -- istSparplan: False
9/209: Basisinformationen -- Do. 05.11. um 10:32 Uhr (Europe/Berlin) -- istSparplan: False
file path/Basisinformationen über Wertpapiere/2020-11-05 10:32 Basisinformationen -  Do. 05.11. um 10:32 Uhr (Europe/Berlin).pdf already in queue. Skipping...
Received error message: '17 E {"errors":[{"errorCode":"BAD_REQUEST","errorField":null,"errorMessage":"Bad Request","meta":{"source":"PLATFORM"}}]}'
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.8/bin/pytr", line 8, in <module>
    sys.exit(main())
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pytr/main.py", line 135, in main
    asyncio.get_event_loop().run_until_complete(dl.dl_loop())
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pytr/dl.py", line 28, in dl_loop
    _subscription_id, subscription, response = await self.tr.recv()
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pytr/api.py", line 246, in recv
    raise TradeRepublicError(subscription_id, subscription, payload)
pytr.api.TradeRepublicError: ('17', {'type': 'timelineDetail', 'id': 'a685439a-606f-4070-980c-830278ade8b5'}, {'errors': [{'errorCode': 'BAD_REQUEST', 'errorField': None, 'errorMessage': 'Bad Request', 'meta': {'source': 'PLATFORM'}}]})

Exception when get details for BMW

Description of the bug
It is missing expected field for DE0005190003 (BMW)

To Reproduce
Steps to reproduce the behavior:

$ pytr details DE0005190003
0:45:26 Logged in
20:45:26 Connecting to websocket ...
20:45:26 Connected to websocket ...
instrumentSuitability: {'instrumentId': 'DE0005190003', 'warnings': ['userExperience']}
Name: BAY.MOTOREN WERKE AG ST
ShortName: BMW
Type: stock
LSX: BMW BAY.MOTOREN WERKE AG ST
TDG: BMW Bayerische Motoren Werke AG
sector: Fahrzeuge
country: Deutschland
index: DAX
index: EUROSTOXX50
Traceback (most recent call last):
  File "/opt/homebrew/bin/pytr", line 8, in <module>
    sys.exit(main())
  File "/opt/homebrew/lib/python3.9/site-packages/pytr/main.py", line 213, in main
    Details(login(phone_no=args.phone_no, pin=args.pin, web=not args.applogin), args.isin).get()
  File "/opt/homebrew/lib/python3.9/site-packages/pytr/details.py", line 89, in get
    self.overview()
  File "/opt/homebrew/lib/python3.9/site-packages/pytr/details.py", line 83, in overview
    self.news()
  File "/opt/homebrew/lib/python3.9/site-packages/pytr/details.py", line 75, in news
    for news in self.neonNews:
AttributeError: 'Details' object has no attribute 'neonNews'

Environment

  • OS: MacOS 12.4 / M1
  • pytr version: 0.1.5
  • Python 3.9.12

Provide pre-build binaries

Thanks for creating pytr!

I'm using it on linux and was not keen to setup a whole Python environment to install pytr. Therefore, I created a Docker image that will build pytr from where I can export the binary. I tweaked it to run on Github action where it will attach the binaries to every release. You can find the repo at https://github.com/yubiuser/pytr-binary and the binaries at https://github.com/yubiuser/pytr-binary/releases/tag/v1.0.0.

I could file a PR at this repo to use the same action/Dockerfile so that you could also attach binaries to your releases (you would need to start using releases, not tags-only). Let me know if you are interesting.

problem with --last_days reproducable

Description of the bug
When --last_days happens to be a weekend (I assume a day where stock has no transfers) the documents are not fetched correctly. I am on the newst version with pytr 0.1.19

To Reproduce
Today is tuesday, 6th feb 2024.

When I run

pytr dl_docs --last_days 9 docs

I get

14:43:43 Found credentials file
14:43:43 Phone: +49151********, PIN: ****
14:43:43 Web session resumed
14:43:43 Logged in
14:43:43 Found 5035 lines in history file
14:43:43 Awaiting #1  timeline
14:43:43 Connecting to websocket ...
14:43:43 Connected to websocket ...
14:43:44 Received #1  timeline, awaiting #2  timeline
14:43:44 Received #2  timeline, awaiting #3  timeline
14:43:44 Received #3  timeline, awaiting #4  timeline
14:43:44 Received #4  timeline, awaiting #5  timeline
14:43:44 Received #6  timeline
14:43:44 Reached last relevant timeline
14:43:44 All timeline details requested
14:43:44 1/2: Kauf Long @127.35 € Merck KGaA Open End Turbo -- Fr. 26.01. um 23:01 Uhr (Europe/Berlin)
14:43:44 2/2: Kauf Long @127.35 € Merck KGaA Open End Turbo -- Fr. 26.01. um 23:01 Uhr (Europe/Berlin)
14:43:44 Received all details
14:43:44 Write deposit entries
14:43:44 Deposit creation finished!
14:43:44 Nothing to download

When I run

pytr dl_docs --last_days 2 docs

(One week later)

I get

14:45:19 Found credentials file
14:45:19 Phone: +49151********, PIN: ****
14:45:19 Web session resumed
14:45:19 Logged in
14:45:19 Found 5035 lines in history file
14:45:19 Awaiting #1  timeline
14:45:19 Connecting to websocket ...
14:45:19 Connected to websocket ...
14:45:19 Received #2  timeline
14:45:19 Reached last relevant timeline
14:45:19 All timeline details requested
14:45:19 1/3: Kauf Long @756.24 € ASML Holding Open End Turbo -- Fr. 02.02. um 17:06 Uhr (Europe/Berlin)
14:45:19 2/3: Verkauf Long @756.24 € ASML Holding Open End Turbo -- Fr. 02.02. um 17:04 Uhr (Europe/Berlin)
14:45:19 3/3: Kauf Long @756.24 € ASML Holding Open End Turbo -- Fr. 02.02. um 17:06 Uhr (Europe/Berlin)
14:45:19 Received all details
14:45:19 Write deposit entries
14:45:20 Deposit creation finished!
14:45:20 Nothing to download

When I run

pytr dl_docs --last_days 1 docs

14:46:17 Found credentials file
14:46:17 Phone: +49151********, PIN: ****
14:46:17 Web session resumed
14:46:17 Logged in
14:46:17 Found 5035 lines in history file
14:46:17 Awaiting #1  timeline
14:46:17 Connecting to websocket ...
14:46:18 Connected to websocket ...
14:46:18 Received #2  timeline
14:46:18 Reached last relevant timeline
14:46:18  1/30: Verkauf Long @756.24 € ASML Holding Open End Turbo -- Fr. 02.02. um 17:04 Uhr (Europe/Berlin)
14:46:18  2/30: Kauf Long @756.24 € ASML Holding Open End Turbo -- Fr. 02.02. um 17:06 Uhr (Europe/Berlin)
14:46:18  3/30: Kauf Long @756.24 € ASML Holding Open End Turbo -- Fr. 02.02. um 17:06 Uhr (Europe/Berlin)
14:46:18  4/30: Kauf Long @131.98 $ Amazon.com Inc Unlimited Turbo -- Mo. 05.02. um 10:45 Uhr (Europe/Berlin)
14:46:18  5/30: Kauf Long @8.93 € Commerzbank Open End Turbo -- Mo. 05.02. um 11:39 Uhr (Europe/Berlin)
14:46:18  6/30: Kauf Long @8.93 € Commerzbank Open End Turbo -- Mo. 05.02. um 11:40 Uhr (Europe/Berlin)
14:46:18  7/30: Kauf Short @17050.61 Pt. DAX® Open End Turbo -- Mo. 05.02. um 13:24 Uhr (Europe/Berlin)
14:46:18  8/30: Verkauf Short @17050.61 Pt. DAX® Open End Turbo -- Mo. 05.02. um 13:14 Uhr (Europe/Berlin)
14:46:18  9/30: Kauf Long @48.46 $ Monster Beverage Open End Turbo -- Mo. 05.02. um 13:03 Uhr (Europe/Berlin)
14:46:18 10/30: Kauf Short @17050.61 Pt. DAX® Open End Turbo -- Mo. 05.02. um 13:04 Uhr (Europe/Berlin)
14:46:18 11/30: Verkauf Short @17050.61 Pt. DAX® Open End Turbo -- Mo. 05.02. um 13:26 Uhr (Europe/Berlin)
14:46:18 12/30: Kauf Long @39.35 $ Bristol-Myers Squibb Co Best Turbo -- Mo. 05.02. um 15:55 Uhr (Europe/Berlin)
14:46:18 13/30: Kauf Long @52.66 $ PayPal Holdings Inc Best Turbo -- Mo. 05.02. um 15:58 Uhr (Europe/Berlin)
14:46:18 14/30: Kauf Long @8.93 € Commerzbank Open End Turbo -- Mo. 05.02. um 15:13 Uhr (Europe/Berlin)
14:46:18 15/30: Kauf Long @80.65 € Sixt Open End Turbo -- Mo. 05.02. um 16:05 Uhr (Europe/Berlin)
14:46:18 16/30: Kauf Long @16555.88 Pt. DAX® Open End Turbo -- Mo. 05.02. um 16:26 Uhr (Europe/Berlin)
14:46:18 17/30: Kauf Long @52.66 $ PayPal Holdings Inc Best Turbo -- Mo. 05.02. um 16:22 Uhr (Europe/Berlin)
14:46:18 18/30: Kauf Long @48.46 $ Monster Beverage Open End Turbo -- Mo. 05.02. um 16:42 Uhr (Europe/Berlin)
14:46:18 19/30: Verkauf Long @16555.88 Pt. DAX® Open End Turbo -- Mo. 05.02. um 16:28 Uhr (Europe/Berlin)
14:46:18 20/30: Verkauf Long @48.46 $ Monster Beverage Open End Turbo -- Mo. 05.02. um 19:21 Uhr (Europe/Berlin)
14:46:18 21/30: Kauf Long @48.46 $ Monster Beverage Open End Turbo -- Mo. 05.02. um 19:22 Uhr (Europe/Berlin)
14:46:18 22/30: Kauf Long @16559.06 Pt. DAX® Open End Turbo -- Di. 06.02. um 09:49 Uhr (Europe/Berlin)
14:46:18 23/30: Verkauf Long @16559.06 Pt. DAX® Open End Turbo -- Di. 06.02. um 10:33 Uhr (Europe/Berlin)
14:46:18 24/30: Kauf Long @8.94 € Commerzbank Open End Turbo -- Di. 06.02. um 09:41 Uhr (Europe/Berlin)
14:46:18 25/30: Verkauf Long @8.94 € Commerzbank Open End Turbo -- Di. 06.02. um 09:41 Uhr (Europe/Berlin)
14:46:18 26/30: Verkauf Long @127.54 € Merck KGaA Open End Turbo -- Di. 06.02. um 14:12 Uhr (Europe/Berlin)
14:46:18 27/30: Kauf Long @605.68 DKK Novo Nordisk A/S Unlimited Turbo -- Di. 06.02. um 10:53 Uhr (Europe/Berlin)
14:46:18 28/30: Verkauf Long @755.63 € ASML Holding Open End Turbo -- Di. 06.02. um 11:11 Uhr (Europe/Berlin)
14:46:18 29/30: Kauf Long @8.94 € Commerzbank Open End Turbo -- Di. 06.02. um 11:21 Uhr (Europe/Berlin)
14:46:18 30/30: Verkauf Long @8.94 € Commerzbank Open End Turbo -- Di. 06.02. um 11:21 Uhr (Europe/Berlin)
14:46:18 Received all details
14:46:18 Write deposit entries
14:46:18 Deposit creation finished!
14:46:18 Nothing to download

Which also includes Friday, which is 5 days back; but seems to do the right thing.

When I run

pytr dl_docs --last_days 8 docs

14:51:22 Found credentials file
14:51:22 Phone: +49151********, PIN: ****
14:51:23 Web session resumed
14:51:23 Logged in
14:51:23 Found 5035 lines in history file
14:51:23 Awaiting #1  timeline
14:51:23 Connecting to websocket ...
14:51:23 Connected to websocket ...
14:51:23 Received #1  timeline, awaiting #2  timeline
14:51:23 Received #2  timeline, awaiting #3  timeline
14:51:23 Received #3  timeline, awaiting #4  timeline
14:51:23 Received #4  timeline, awaiting #5  timeline
14:51:23 Received #6  timeline
14:51:23 Reached last relevant timeline
14:51:23   1/150: Verkauf Long @16800.17 Pt. Nasdaq-100 Index® Open End Turbo -- Mo. 29.01. um 08:21 Uhr (Europe/Berlin)
14:51:23   2/150: Kauf Long @8.92 € Commerzbank Open End Turbo -- Mo. 29.01. um 10:03 Uhr (Europe/Berlin)
14:51:24   3/150: Kauf Long @127.35 € Merck KGaA Open End Turbo -- Fr. 26.01. um 23:01 Uhr (Europe/Berlin)
14:51:24   4/150: Kauf Long @127.35 € Merck KGaA Open End Turbo -- Fr. 26.01. um 23:01 Uhr (Europe/Berlin)
14:51:24   5/150: Kauf Long @755.62 € ASML Holding Open End Turbo -- Mo. 29.01. um 09:21 Uhr (Europe/Berlin)
14:51:24   6/150: Verkauf Long @8.92 € Commerzbank Open End Turbo -- Mo. 29.01. um 12:41 Uhr (Europe/Berlin)
14:51:24   7/150: Verkauf Long @8.92 € Commerzbank Open End Turbo -- Mo. 29.01. um 10:36 Uhr (Europe/Berlin)
14:51:24   8/150: Kauf Long @8.92 € Commerzbank Open End Turbo -- Mo. 29.01. um 11:02 Uhr (Europe/Berlin)
.
. deleted many lines
.
14:51:25 145/150: Kauf Long @16559.06 Pt. DAX® Open End Turbo -- Di. 06.02. um 09:49 Uhr (Europe/Berlin)
14:51:25 146/150: Kauf Long @8.94 € Commerzbank Open End Turbo -- Di. 06.02. um 11:21 Uhr (Europe/Berlin)
14:51:25 147/150: Verkauf Long @755.63 € ASML Holding Open End Turbo -- Di. 06.02. um 11:11 Uhr (Europe/Berlin)
14:51:25 148/150: Verkauf Long @8.94 € Commerzbank Open End Turbo -- Di. 06.02. um 11:21 Uhr (Europe/Berlin)
14:51:25 149/150: Kauf Long @605.68 DKK Novo Nordisk A/S Unlimited Turbo -- Di. 06.02. um 10:53 Uhr (Europe/Berlin)
14:51:25 150/150: Verkauf Long @127.54 € Merck KGaA Open End Turbo -- Di. 06.02. um 14:12 Uhr (Europe/Berlin)
14:51:25 Received all details
14:51:25 Write deposit entries
14:51:25 Deposit creation finished!
14:51:25 Nothing to download

If you need more examples for reproduction, than tell me, I do not want to fill up this post too much.

thank you
Juergen

BAD_SUBSCRIPTION_TYPE error for pytr portfolio

Description of the bug
I tried to read out my portfolio with pytr portfolio, but got a BAD_SUBSCRIPTION_TYPE error response

To Reproduce

  1. Successfully logged in
  2. Ran the command pytr portfolio
  3. See error

Expected behavior
See my current portfolio

Error log

21:49:12 Found credentials file
21:49:12 Phone: +49176********, PIN: ****
21:49:12 Web session resumed
21:49:12 Logged in
21:49:12 Connecting to websocket ...
21:49:12 Connected to websocket ...
21:49:13 Received error message: '1 E {"errors":[{"errorCode":"BAD_SUBSCRIPTION_TYPE","errorField":null,"errorMessage":"Unknown topic type","meta":{"source":"MAPPER"}}]}'
Traceback (most recent call last):
  File "/home/martin/.local/bin/pytr", line 8, in <module>
    sys.exit(main())
  File "/home/martin/.local/lib/python3.10/site-packages/pytr/main.py", line 215, in main
    Portfolio(login(phone_no=args.phone_no, pin=args.pin, web=not args.applogin)).get()
  File "/home/martin/.local/lib/python3.10/site-packages/pytr/portfolio.py", line 73, in get
    asyncio.get_event_loop().run_until_complete(self.portfolio_loop())
  File "/usr/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "/home/martin/.local/lib/python3.10/site-packages/pytr/portfolio.py", line 16, in portfolio_loop
    _subscription_id, subscription, response = await self.tr.recv()
  File "/home/martin/.local/lib/python3.10/site-packages/pytr/api.py", line 352, in recv
    raise TradeRepublicError(subscription_id, subscription, payload)
pytr.api.TradeRepublicError: ('1', {'type': 'portfolio'}, {'errors': [{'errorCode': 'BAD_SUBSCRIPTION_TYPE', 'errorField': None, 'errorMessage': 'Unknown topic type', 'meta': {'source': 'MAPPER'}}]})

Environment

  • OS: Linux
  • pytr version: 0.1.5

Additional context
It was still working a couple of week ago. Other commands still work. Did they change the API?

ValueError: Connection Error: failed 29 Segmentation fault after dl_docs

Description of the bug
After trying to download documents via dl_docs im getting following error:

Error log
$ pytr -v debug dl_docs .
2023-10-02 20:43:21+0200 main DEBUG logging is set to debug
2023-10-02 20:43:21+0200 account INFO Found credentials file
2023-10-02 20:43:21+0200 account INFO Phone: ********, PIN: ****
2023-10-02 20:43:21+0200 account INFO Web session resumed
2023-10-02 20:43:21+0200 account INFO Logged in
2023-10-02 20:43:21+0200 dl INFO Found 419 lines in history file
2023-10-02 20:43:21+0200 utils INFO Awaiting timeline
2023-10-02 20:43:21+0200 api INFO Connecting to websocket ...
Traceback (most recent call last):
File "", line 198, in _run_module_as_main
File "", line 88, in run_code
File "C:\Users\xxxxxx\AppData\Local\Programs\Python\Python311\Scripts\pytr.exe_main
.py", line 7, in
File "C:\Users\xxxxxx\AppData\Local\Programs\Python\Python311\Lib\site-packages\pytr\main.py", line 206, in main
asyncio.get_event_loop().run_until_complete(dl.dl_loop())
File "C:\Users\xxxxxx\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 653, in run_until_complete
return future.result()
File "C:\Users\xxxxxx\AppData\Local\Programs\Python\Python311\Lib\site-packages\pytr\dl.py", line 59, in dl_loop
await self.tl.get_next_timeline(max_age_timestamp=self.since_timestamp)
File "C:\Users\xxxxxx\AppData\Local\Programs\Python\Python311\Lib\site-packages\pytr\utils.py", line 236, in get_next_timeline
await self.tr.timeline()
File "C:\Users\xxxxxx\AppData\Local\Programs\Python\Python311\Lib\site-packages\pytr\api.py", line 443, in timeline
return await self.subscribe({'type': 'timeline', 'after': after})
File "C:\Users\xxxxxx\AppData\Local\Programs\Python\Python311\Lib\site-packages\pytr\api.py", line 293, in subscribe
ws = await self._get_ws()
File "C:\Users\xxxxxx\AppData\Local\Programs\Python\Python311\Lib\site-packages\pytr\api.py", line 279, in _get_ws
raise ValueError(f'Connection Error: {response}')
ValueError: Connection Error: failed 29
Segmentation fault

To Reproduce
Steps to reproduce the behavior:

Ran the command pytr dl_docs .

Environment

  • Windows 10
  • pytr version: 0.0.15

Additional context
Tried python 3.7 python 3.9 and python 3.11
It seems that after the Trade Repbulic update they changed the API?!

Session is not invalidated when a new login with different number occurs

Description of the bug
When working with multiple accounts even if a different phone number and pin are supplied the previous session gets resumed.

To Reproduce
Login using pytr login using an existing key file. Then pytr login -n <somenumber> -p <somepin>. Might as well save a new key file. Now pytr dl_docs will use the first account not the one which was logged in last (given the session is still valid).

10:58:25 Found credentials file
10:58:25 Phone: +49***********, PIN: ****
10:58:29 Web session resumed.                           // <----- This should not be
10:58:29 Logged in
10:58:29 Created history file

Expected behavior
When logging in with a number other than the one the active session is linked to, I expect a the session to be invalidated and a new session to start.

Error log

Environment

  • OS: MacOS
  • pytr version: 0.1.5

pytr portfolio gets stuck while unsubscribeing

Description of the bug
When I run pytr -v debug portfolio it gets stuck while unsubscribing ID 13 which has ISIN US67066G1040 (Nvidia) for me.

To Reproduce
Steps to reproduce the behavior:

  1. Ran the command pytr -v debug portfolio
  2. See error

Expected behavior
A clear and concise description of what you expected to happen.

Error log

...
2024-04-02 21:01:33+0200 api       DEBUG    Unsubscribing: 13

Nothing happens after that line. I have to kill it with ctrl+c

Environment

  • OS: MacOS
  • pytr version: 0.1.9

Additional context
Add any other context about the problem here.

ValueError: Connection Error: failed 31

I tried starting the document download today which resulted in the error "ValueError: Connection Error: failed 31". This happened during the step "Connection to websocket" after login was successful.

download only after certain date

I love what you created here - so first of all: Thanks a lot!

It would be great for repetitive use to set a start date for downloads to not downloading all files again that have already been downloaded

Permission error for export_transactions

Description of the bug
When calling the export_transactions function, I get a permission denied error.
Probably the input and ouput should be something else. Could you please clearify that and maybe add it in the code documentation.
Thank you very much!

Error log

(base) C:\Users\49176\Documents\trade_republic>pytr export_transactions C:\Users\49176\Documents\trade_republic C:\Users\49176\Documents\trade_republic
Traceback (most recent call last):
  File "C:\Users\49176\anaconda3\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\49176\anaconda3\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\49176\anaconda3\Scripts\pytr.exe\__main__.py", line 7, in <module>
  File "C:\Users\49176\anaconda3\lib\site-packages\pytr\main.py", line 168, in main
    export_transactions(args.input, args.output, args.lang)
  File "C:\Users\49176\anaconda3\lib\site-packages\pytr\utils.py", line 174, in export_transactions
    with open(input_path, encoding='utf-8') as f:
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\49176\\Documents\\trade_republic'

After calling the function I added the folder previously generated by dl_docs and the same folder, to save the document there.
Are these principally the right steps?

Error on login

Description of the bug

Traceback (most recent call last):
  File "/opt/homebrew/bin/pytr", line 8, in <module>
    sys.exit(main())
  File "/opt/homebrew/lib/python3.9/site-packages/pytr/main.py", line 129, in main
    dl = DL(login(web=weblogin), args.output, args.format, since_timestamp=since_timestamp)
  File "/opt/homebrew/lib/python3.9/site-packages/pytr/account.py", line 77, in login
    for remaining in range(countdown):
TypeError: 'float' object cannot be interpreted as an integer

I receive the error message above while trying to log in. I am entering nothing as "code" since I didn't receive a notification on my mobile device. Older versions used to work.

pytr login

Environment

  • OS: MacOS 12.0.1
  • Version: 0.0.13

Download Doc fails with API error

Description of the bug
When downloading all docs from timeline, it fails always around the same area.

To Reproduce
Steps to reproduce the behavior:

  1. Go to /Users/Christian/Documents/TR/pdf
  2. Ran the command pytr dl_docs ./
  3. Wait for documents to load
  4. See error

Expected behavior
All documents download, eventually (API-) failing documents are ignored and outputted to the end (e.g. for manual validation via app).

Error log

21:48:46 573/757: Verkauf [redacted]
21:48:46 Received error message: '600 E {"errors":[{"errorCode":"UNKNOWN_ERROR","errorField":null,"errorMessage":"Unknown error","meta":{"source":"PLATFORM"}}]}'
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.10/bin/pytr", line 8, in <module>
    sys.exit(main())
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pytr/main.py", line 130, in main
    asyncio.get_event_loop().run_until_complete(dl.dl_loop())
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/base_events.py", line 641, in run_until_complete
    return future.result()
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pytr/dl.py", line 39, in dl_loop
    _subscription_id, subscription, response = await self.tr.recv()
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pytr/api.py", line 345, in recv
    raise TradeRepublicError(subscription_id, subscription, payload)
pytr.api.TradeRepublicError: ('600', {'type': 'timelineDetail', 'id': '[redacted]'}, {'errors': [{'errorCode': 'UNKNOWN_ERROR', 'errorField': None, 'errorMessage': 'Unknown error', 'meta': {'source': 'PLATFORM'}}]})
Christians-MacBook-Air:pdf Christian$ 

Environment

  • OS: Mac OS 10.15.7 Darwin Christians-MacBook-Air.local 19.6.0 Darwin Kernel Version 19.6.0: Tue Nov 10 00:10:30 PST 2020; root:xnu-6153.141.10~1/RELEASE_X86_64 x86_64
  • pytr version: 0.0.18

Additional context
Download works until reaching the same time area via e.g.
pytr dl_docs --last_days 65 ./

Why is it optional to save credentials when pytr crashes as soon as you refuse to save?

Description of the bug
Why is it optional to save credentials when pytr crashes as soon as you refuse to save?

To Reproduce
Steps to reproduce the behavior:

  1. Run pytr login
  2. Refuse to save the credentials
  3. See error

Expected behavior
Would be great if the program works without me saving the credentials

Error log

C:\Users\Virtual>pytr login
13:07:02 Credentials file not found
Please enter your TradeRepbulic phone number in the format +4912345678:
+4912345678
Please enter your TradeRepbulic pin:
0000
Save credentials? Type "y" to save credentials:
n
13:07:24 Credentials not saved
Traceback (most recent call last):
  File "c:\users\virtual\appdata\local\programs\python\python38-32\lib\site-packages\pytr\api.py", line 89, in __init__
    with open(CREDENTIALS_FILE, 'r') as f:
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\Virtual\\.pytr\\credentials'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\users\virtual\appdata\local\programs\python\python38-32\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\users\virtual\appdata\local\programs\python\python38-32\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\Virtual\AppData\Local\Programs\Python\Python38-32\Scripts\pytr.exe\__main__.py", line 7, in <module>
  File "c:\users\virtual\appdata\local\programs\python\python38-32\lib\site-packages\pytr\main.py", line 143, in main
    login(phone_no=args.phone_no, pin=args.pin, web=weblogin)
  File "c:\users\virtual\appdata\local\programs\python\python38-32\lib\site-packages\pytr\account.py", line 61, in login
    tr = TradeRepublicApi()
  File "c:\users\virtual\appdata\local\programs\python\python38-32\lib\site-packages\pytr\api.py", line 94, in __init__
    raise ValueError(f'phone_no and pin must be specified explicitly or via {CREDENTIALS_FILE}')
ValueError: phone_no and pin must be specified explicitly or via C:\Users\Virtual\.pytr\credentials

Environment

  • OS: Windows
  • Version: pytr-0.0.9

web session remains open - working with multiple accounts not possible

Description of the bug
I'm trying to download documents from two different Trade Republic accounts.
But the web session for the first account remains active and it is not possible to retrieve documents from the second account afterwards.

To Reproduce

Steps to reproduce the behavior:

  1. run pytr dl_docs --last_days 180 .
  2. Enter the TradeRepbulic phone number for the first account.
  3. Enter the TradeRepbulic pin for the first account.
  4. Do not save credentials.

Log confirms:

hh:mm:ss Credentials not saved

Documents for the first account are downloaded properly.

  1. run pytr dl_docs --last_days 180 . again
  2. Enter the TradeRepbulic phone number for the second account.
  3. Enter the TradeRepbulic pin for the second account.
  4. Do NOT save credentials.

Log says:

hh:mm:ss Credentials not saved
hh:mm:ss Web session resumed
hh:mm:ss Logged in

The log give the impression, that the login to the second account was successful. But actually you get or remain logged in into the first account. So documents from the second account are not downloaded. Instead documents from the first account are downloaded again.

Expected behavior
An existing web session gets closed, when pytr gets called with different credentials.
Login into the second Trade Republic account actually happens and documents from the second Trade Republic account are downloaded.

Error log
n.a.

Environment

  • OS: MacOS 12.1
  • pytr version: 0.0.18

Additional context
n.a.

Filenames - Windows compatible

Description of the bug
I have been using pytr for a few days. I load the PDF's into a folder that is shared via SMB. Unfortunately I can't open some files under Windows, because they are named with characters that Windows doesn't support.

To Reproduce
Steps to reproduce the behavior:

  1. Run the command pytr dl_docs <smb_dir>
  2. Open the SMB Share
  3. Try to open a file

Expected behavior
The files should be saved Windows compliant.

Error log
N/A

Environment

  • OS: RaspberryPiOS armv7
  • pytr version: 0.0.15

Additional context
I access the SMB share with multiple Windows 10 (21H2) devices.

dl_docs: error: the following arguments are required: PATH

Description of the bug
Thanks for the great work. I used the tool for the first time today. Login, portfolio and the other functions work perfectly. I only get the error message for the dl_docs:

Error log

(virtualenv) C:\Users\guowe\PycharmProjects\traderepublic>pytr dl_docs
usage: pytr dl_docs [-h] [--format FORMAT_STRING] [--last_days DAYS] PATH
pytr dl_docs: error: the following arguments are required: PATH

Environment

  • OS: Windows
  • Version: 11
  • Python: 3.10

Thanks a lot for the work! Do you need more information regarding the error log?

Bad Request Messages

I'm not sure what it is. But I get multiple Bad Request Messages

To Reproduce

  1. pytr dl_docs .

Error log

2023-02-14 23:37:01+0100 utils     INFO     376/405: Siltronic -- Sparplan
2023-02-14 23:37:01+0100 dl        DEBUG    File Sparplan/Löschbestätigung/2023-02-06 Siltronic.pdf already in queue. Skipping...
2023-02-14 23:37:01+0100 dl        DEBUG    File Sparplan/Abrechnung Ausführung/2023-02-02 Siltronic 2.pdf already in queue. Skipping...
2023-02-14 23:37:01+0100 dl        DEBUG    File Sparplan/Abrechnung Ausführung/2023-01-02 Siltronic 1.pdf already in queue. Skipping...
2023-02-14 23:37:01+0100 dl        DEBUG    File Sparplan/Kosteninformation/2022-12-17 Siltronic.pdf already in queue. Skipping...
2023-02-14 23:37:01+0100 dl        DEBUG    File Sparplan/Auftragsbestätigung/2022-12-17 Siltronic.pdf already in queue. Skipping...
2023-02-14 23:37:01+0100 api       DEBUG    Received message: '390 C'
2023-02-14 23:37:01+0100 api       DEBUG    Received message: '393 E {"errors":[{"errorCode":"BAD_REQUEST","errorField":null,"errorMessage":"Bad Request","meta":{"source":"PLATFORM"}}]}'
2023-02-14 23:37:01+0100 api       ERROR    Received error message: '393 E {"errors":[{"errorCode":"BAD_REQUEST","errorField":null,"errorMessage":"Bad Request","meta":{"source":"PLATFORM"}}]}'
2023-02-14 23:37:01+0100 api       DEBUG    Unsubscribing: 393
2023-02-14 23:37:01+0100 dl        CRITICAL ('393', {'type': 'timelineDetail', 'id': '8772498d5-35c0-4d84-9774-5665e8dd1254'}, {'errors': [{'errorCode': 'BAD_REQUEST', 'errorField': None, 'errorMessage': 'Bad Request', 'meta': {'source': 'PLATFORM'}}]})
2023-02-14 23:37:01+0100 utils     INFO     377/405: Siltronic -- Sparplan

Environment

  • OS: Ubuntu 22.04.1 LTS
  • pytr version: 0.1.5

pytr dl_docs --last_days 7 docs does not DL PDF, although they are there (checked online with TR)

Description of the bug
Hi,
there is an issue with the last_days switch in Version 0.1.9

This is my commandline
pytr dl_docs --last_days 7 docs

which connects well, and than shows:

10:21:16 1/4: Verkauf Short @15974.51 Pt. DAX® Open End Turbo -- Fr. 17.11. um 21:51 Uhr (Europe/Berlin)
10:21:16 2/4: Kauf Short @15974.51 Pt. DAX® Open End Turbo -- Fr. 17.11. um 17:05 Uhr (Europe/Berlin)
10:21:16 3/4: Verkauf Short @15974.51 Pt. DAX® Open End Turbo -- Fr. 17.11. um 21:50 Uhr (Europe/Berlin)
10:21:16 4/4: Verkauf Short @15974.51 Pt. DAX® Open End Turbo -- Fr. 17.11. um 21:52 Uhr (Europe/Berlin)
10:21:16 Received all details
10:21:16 Write deposit entries
10:21:16 Deposit creation finished!
10:21:16 Nothing to download

Which are very old PDF dates dates, as today is the 27.11.2023 (and they are definitely not in the timeframe of 7 days)
I double checked online. The documents I was hoping to download where already produced by TR.

Without the "--last_days" command, the files are downloaded. (30 seconds later)

pytr dl_docs docs

10:21:44 384/390: Kauf Long @15887.30 Pt. DAX® Open End Turbo -- Mo. 27.11. um 09:00 Uhr (Europe/Berlin)
10:21:44 385/390: Kauf Long @116.89 € Airbus Open End Turbo -- Fr. 24.11. um 20:15 Uhr (Europe/Berlin)
10:21:44 386/390: Verkauf Long @128.48 € SAP Open End Turbo -- Mo. 27.11. um 09:38 Uhr (Europe/Berlin)
10:21:44 387/390: Verkauf Long @15887.30 Pt. DAX® Open End Turbo -- Mo. 27.11. um 09:10 Uhr (Europe/Berlin)
10:21:44 388/390: Verkauf Long @15887.30 Pt. DAX® Open End Turbo -- Mo. 27.11. um 09:16 Uhr (Europe/Berlin)
10:21:44 389/390: Verkauf Long @15887.30 Pt. DAX® Open End Turbo -- Mo. 27.11. um 09:07 Uhr (Europe/Berlin)
10:21:44 390/390: Verkauf Long @15887.30 Pt. DAX® Open End Turbo -- Mo. 27.11. um 09:04 Uhr (Europe/Berlin)
10:21:44 Received all details
10:21:44 Write deposit entries
10:21:44 Deposit creation finished!
10:21:44 Waiting for downloads to complete..
10:21:45 Done.

To Reproduce
...

Expected behavior

Error log

No errors.

Environment

  • OS: MacOS, but I bet it does not matter
  • pytr version: 0.1.9

Additional context
As you see, I trade a lot any maybe this is the issue in this case. Again: Great program, I love it, and it works for me perfect, without the --last_days 7

Terminal can't handle spaces in path

Description of the bug
The download path will not be accepted if it contains a directory with spaces, e.g. "Trade Republic".

To Reproduce
Steps to reproduce the behavior:

  1. Ran the command "pytr dl_docs C:\Daten\Trade Republic"
  2. See output "usage: pytr [-h] [-s {bash,zsh,tcsh}] [-v {warning,info,debug}] [--applogin] [-V]
    {help,login,portfolio,dl_docs,get_price_alarms,details,set_price_alarms} ...
    pytr: error: unrecognized arguments: Republic"
  3. No download is performed

Expected behavior
Download of docs to the given/existing path

Error log
pytr: error: unrecognized arguments: Republic

Environment

  • OS: Windows 10 20H2
  • pytr version:
  • Python 3.9

Customize timeformat in filenames

Hello,
thank you for your great work! pytr is a really helpful tool!

I think it would be great if we could format the datetime within the filename.
My problem with the slash as time delimiter is that OneDrive cannot upload files containing a slash.

I just quickly looked into the code and thought one could parse the date and time to format it according to a user defined format, e.g. provided by another argument like --timeFormat with a default value of the existing behavior or an ISO format.

What do you think about it? If you need any support, I would be happy to help.
Thank you!

export_transactions is an invalid command

First of all thanks for the great tool.

I would like to dowload the csv files to import it to portfolio performance. But the command export_transactions seems to be not available anymore. How can I do that? Thanks

Export investments as CSV

Is your feature request related to a problem? Please describe.

Da TradeRepublic nicht die beste Übersicht über die Investments bietet wollte ich 3rd Party Portfolio Tracker (Delta.app oder CoinTracking) nutzen um meine Investments (vorallem Crypto) dort übersichtlich einsehen zu können um Haltefristen etc. einhalten zu können.

Describe the solution you'd like
A clear and concise description of what you want to happen.

Eine weitere funktion wie z.B. export_investments wäre cool. Diese könnte ähnlich wie export_transactions aufgebaut sein, nur mit dem unterschied, dass nicht auf keywörter wie "Einzahlung", "Bonuszahlungen", "Auszahlungen" und "Reinvestierung" gematcht wird, sondern eventuell auf event['cashChangeAmount'].

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Stuck at 'connecting to websocket'

Discussed in #12

Originally posted by GordonMohrin November 25, 2021
I downloaded my files correctly on 08.11.2021. Now i wanted to update them but the program is stuck without a timeout.
I recreated my credentials file.
I am on Version 0.0.9.
Using git bash on windows.

$ pip install --upgrade pytr
Requirement already satisfied: pytr in c:\users\admin\appdata\local\programs\python\python39\lib\site-packages (0.0.8)
Collecting pytr
  Downloading pytr-0.0.9-py3-none-any.whl (21 kB)
Requirement already satisfied: pygments in c:\users\admin\appdata\local\programs\python\python39\lib\site-packages (from pytr) (2.10.0)
Requirement already satisfied: websockets in c:\users\admin\appdata\local\programs\python\python39\lib\site-packages (from pytr) (10.0)
Requirement already satisfied: coloredlogs in c:\users\admin\appdata\local\programs\python\python39\lib\site-packages (from pytr) (15.0.1)
Requirement already satisfied: requests-futures in c:\users\admin\appdata\local\programs\python\python39\lib\site-packages (from pytr) (1.0.0)
Requirement already satisfied: ecdsa in c:\users\admin\appdata\local\programs\python\python39\lib\site-packages (from pytr) (0.17.0)
Requirement already satisfied: shtab in c:\users\admin\appdata\local\programs\python\python39\lib\site-packages (from pytr) (1.4.2)
Requirement already satisfied: humanfriendly>=9.1 in c:\users\admin\appdata\local\programs\python\python39\lib\site-packages (from coloredlogs->pytr) (10.0)
Requirement already satisfied: pyreadline3 in c:\users\admin\appdata\local\programs\python\python39\lib\site-packages (from humanfriendly>=9.1->coloredlogs->pytr) (3.3)
Requirement already satisfied: six>=1.9.0 in c:\users\admin\appdata\local\programs\python\python39\lib\site-packages (from ecdsa->pytr) (1.16.0)
Requirement already satisfied: requests>=1.2.0 in c:\users\admin\appdata\local\programs\python\python39\lib\site-packages (from requests-futures->pytr) (2.26.0)
Requirement already satisfied: idna<4,>=2.5 in c:\users\admin\appdata\local\programs\python\python39\lib\site-packages (from requests>=1.2.0->requests-futures->pytr) (3.3)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\admin\appdata\local\programs\python\python39\lib\site-packages (from requests>=1.2.0->requests-futures->pytr) (2021.10.8)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in c:\users\admin\appdata\local\programs\python\python39\lib\site-packages (from requests>=1.2.0->requests-futures->pytr) (1.26.7)
Requirement already satisfied: charset-normalizer~=2.0.0 in c:\users\admin\appdata\local\programs\python\python39\lib\site-packages (from requests>=1.2.0->requests-futures->pytr) (2.0.7)
Installing collected packages: pytr
  Attempting uninstall: pytr
    Found existing installation: pytr 0.0.8
    Uninstalling pytr-0.0.8:
      Successfully uninstalled pytr-0.0.8
Successfully installed pytr-0.0.9
WARNING: You are using pip version 21.1.1; however, version 21.3.1 is available.
You should consider upgrading via the 'c:\users\admin\appdata\local\programs\python\python39\python.exe -m pip install --upgrade pip' command.

admin@DESKTOP-69OHS5E MINGW64 /e/code/pytr2/pytr (master)
$ pytr dl_docs e:/trdocs
13:43:17 Found credentials file
13:43:17 Phone: +49XXXXXX, PIN: XXXX
13:43:17 Web session resumed
13:43:17 Logged in
13:43:17 Awaiting #1  timeline
13:43:17 Connecting to websocket ...

admin@DESKTOP-69OHS5E MINGW64 /e/code/pytr2/pytr (master)
$ pytr portfolio
13:58:17 Found credentials file
13:43:17 Phone: +49XXXXXX, PIN: XXXX
13:58:17 Web session resumed
13:58:17 Logged in
13:58:17 Connecting to websocket ...

The exception after leaving it running for an hour:

Traceback (most recent call last):
  File "c:\users\admin\appdata\local\programs\python\python39\lib\asyncio\windows_events.py", line 457, in finish_recv
    return ov.getresult()
OSError: [WinError 64] The specified network name is no longer available

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\users\admin\appdata\local\programs\python\python39\lib\site-packages\websockets\legacy\protocol.py", line 944, in transfer_data
    message = await self.read_message()
  File "c:\users\admin\appdata\local\programs\python\python39\lib\site-packages\websockets\legacy\protocol.py", line 1013, in read_message
    frame = await self.read_data_frame(max_size=self.max_size)
  File "c:\users\admin\appdata\local\programs\python\python39\lib\site-packages\websockets\legacy\protocol.py", line 1089, in read_data_frame
    frame = await self.read_frame(max_size)
  File "c:\users\admin\appdata\local\programs\python\python39\lib\site-packages\websockets\legacy\protocol.py", line 1144, in read_frame
    frame = await Frame.read(
  File "c:\users\admin\appdata\local\programs\python\python39\lib\site-packages\websockets\legacy\framing.py", line 70, in read
    data = await reader(2)
  File "c:\users\admin\appdata\local\programs\python\python39\lib\asyncio\streams.py", line 723, in readexactly
    await self._wait_for_data('readexactly')
  File "c:\users\admin\appdata\local\programs\python\python39\lib\asyncio\streams.py", line 517, in _wait_for_data
    await self._waiter
  File "c:\users\admin\appdata\local\programs\python\python39\lib\asyncio\proactor_events.py", line 280, in _loop_reading
    data = fut.result()
  File "c:\users\admin\appdata\local\programs\python\python39\lib\asyncio\windows_events.py", line 812, in _poll
    value = callback(transferred, key, ov)
  File "c:\users\admin\appdata\local\programs\python\python39\lib\asyncio\windows_events.py", line 461, in finish_recv
    raise ConnectionResetError(*exc.args)
ConnectionResetError: [WinError 64] The specified network name is no longer available

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "c:\users\admin\appdata\local\programs\python\python39\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\users\admin\appdata\local\programs\python\python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\admin\AppData\Local\Programs\Python\Python39\Scripts\pytr.exe\__main__.py", line 7, in <module>
  File "c:\users\admin\appdata\local\programs\python\python39\lib\site-packages\pytr\main.py", line 161, in main
    Portfolio(login(web=weblogin)).get()
  File "c:\users\admin\appdata\local\programs\python\python39\lib\site-packages\pytr\portfolio.py", line 73, in get
    asyncio.get_event_loop().run_until_complete(self.portfolio_loop())
  File "c:\users\admin\appdata\local\programs\python\python39\lib\asyncio\base_events.py", line 642, in run_until_complete
    return future.result()
  File "c:\users\admin\appdata\local\programs\python\python39\lib\site-packages\pytr\portfolio.py", line 11, in portfolio_loop
    await self.tr.portfolio()
  File "c:\users\admin\appdata\local\programs\python\python39\lib\site-packages\pytr\api.py", line 380, in portfolio
    return await self.subscribe({'type': 'portfolio'})
  File "c:\users\admin\appdata\local\programs\python\python39\lib\site-packages\pytr\api.py", line 288, in subscribe
    ws = await self._get_ws()
  File "c:\users\admin\appdata\local\programs\python\python39\lib\site-packages\pytr\api.py", line 271, in _get_ws
    response = await self._ws.recv()
  File "c:\users\admin\appdata\local\programs\python\python39\lib\site-packages\websockets\legacy\protocol.py", line 552, in recv
    await self.ensure_open()
  File "c:\users\admin\appdata\local\programs\python\python39\lib\site-packages\websockets\legacy\protocol.py", line 920, in ensure_open
    raise self.connection_closed_exc()
websockets.exceptions.ConnectionClosedError: no close frame received or sent
```</div>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.