Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crypto gets timeout #48

Closed
GordonInDaHouse opened this issue Nov 29, 2023 · 9 comments
Closed

Crypto gets timeout #48

GordonInDaHouse opened this issue Nov 29, 2023 · 9 comments
Labels
bug Something isn't working

Comments

@GordonInDaHouse
Copy link

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

@GordonInDaHouse GordonInDaHouse added the bug Something isn't working label Nov 29, 2023
@cyrilpawelko
Copy link
Contributor

cyrilpawelko commented Feb 24, 2024

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
Copy link

CorsiDanilo commented May 3, 2024

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
Copy link
Contributor

@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
Copy link

@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
Copy link
Contributor

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

@cyrilpawelko
Copy link
Contributor

@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
Copy link

@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
Copy link
Contributor

@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
Copy link
Collaborator

This issue should be fixed in the current master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants