pytr-org / pytr

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

Crypto gets timeout #48

Closed GordonInDaHouse closed 2 days ago

GordonInDaHouse commented 7 months ago

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

cyrilpawelko commented 4 months ago

Got something similar. Not with a crypto, but with a value not on LSX. pytr/portfolio.py sets ticker to only query LSX : https://github.com/marzzzello/pytr/blob/4e3f141bc70546bc79407ad8acc17e20c07052e9/pytr/portfolio.py#L47

I fixed it in my own script, by querying the first exchange found in intrumentId :

portfolio=tr.run_blocking(tr.compact_portfolio())
for position in portfolio['positions'] :
    isin = position['instrumentId']
# Get instrument details
    instrument = tr.run_blocking(tr.instrument_details(isin))
    exchange=instrument['exchangeIds'][0]
# Get price
    ticker = tr.run_blocking(tr.ticker(isin,exchange=exchange))
    price = ticker['last']['price']
CorsiDanilo commented 2 months ago

Got something similar. Not with a crypto, but with a value not on LSX. pytr/portfolio.py sets ticker to only query LSX :

https://github.com/marzzzello/pytr/blob/4e3f141bc70546bc79407ad8acc17e20c07052e9/pytr/portfolio.py#L47

I fixed it in my own script, by querying the first exchange found in intrumentId :

portfolio=tr.run_blocking(tr.compact_portfolio())
for position in portfolio['positions'] :
    isin = position['instrumentId']
# Get instrument details
    instrument = tr.run_blocking(tr.instrument_details(isin))
    exchange=instrument['exchangeIds'][0]
# Get price
    ticker = tr.run_blocking(tr.ticker(isin,exchange=exchange))
    price = ticker['last']['price']

@cyrilpawelko I also have a similar problem, I don't know if it relates precisely to that but I wanted to ask you specifically where did you add that code? Did you have to edit anything else?

cyrilpawelko commented 2 months ago

@CorsiDanilo I wrote my own synchronous script using pytr librairies. I guess portfolio.py:47 should extract an exchangeId from instrument_details, but I was not able to do it.

CorsiDanilo commented 2 months ago

@CorsiDanilo I wrote my own synchronous script using pytr librairies. I guess portfolio.py:47 should extract an exchangeId from instrument_details, but I was not able to do it.

@cyrilpawelko Could you share it? I wanted to try and fix this too..

cyrilpawelko commented 2 months ago

@CorsiDanilo Here is my script (work in progress), renamed in .txt to allow uploading : custom.txt

cyrilpawelko commented 2 months ago

@CorsiDanilo I managed to have a seemingly working porfolio.py : Let me know (you and others) if it works for you, I'll make a pull request. portfolio.py.txt

CorsiDanilo commented 2 months ago

@CorsiDanilo I managed to have a seemingly working porfolio.py : Let me know (you and others) if it works for you, I'll make a pull request. portfolio.py.txt

@cyrilpawelko thanks it worked!

Is it now possible to export all transactions to a file (such as .csv)?

I tried with the command:

pytr portfolio -o /path/to/output

But apparently the function p.portfolio_to_csv has not been implemented. It gives me this error:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "c:\Users\danil\Documents\Repositories\NW-SCRIPTS\.venv\Scripts\pytr.exe\__main__.py", line 7, in <module>
  File "c:\Users\danil\Documents\Repositories\NW-SCRIPTS\.venv\Lib\site-packages\pytr\main.py", line 223, in main
    p.portfolio_to_csv(args.output)
    ^^^^^^^^^^^^^^^^^^
AttributeError: 'Portfolio' object has no attribute 'portfolio_to_csv'. Did you mean: 'portfolio_loop'?
cyrilpawelko commented 2 months ago

@CorsiDanilo The modifications were made to an old version of pytr. I've just created an up-to-date pull request You'll find the correct file here : https://github.com/cyrilpawelko/pytr/blob/master/pytr/portfolio.py

Katzmann1983 commented 2 days ago

This issue should be fixed in the current master.