Giter VIP home page Giter VIP logo

Comments (9)

cyrilpawelko avatar cyrilpawelko commented on July 29, 2024 1

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']

from pytr.

cyrilpawelko avatar cyrilpawelko commented on July 29, 2024 1

@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

from pytr.

cyrilpawelko avatar cyrilpawelko commented on July 29, 2024 1

@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

from pytr.

CorsiDanilo avatar CorsiDanilo commented on July 29, 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?

from pytr.

cyrilpawelko avatar cyrilpawelko commented on July 29, 2024

@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.

from pytr.

CorsiDanilo avatar CorsiDanilo commented on July 29, 2024

@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..

from pytr.

cyrilpawelko avatar cyrilpawelko commented on July 29, 2024

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

from pytr.

CorsiDanilo avatar CorsiDanilo commented on July 29, 2024

@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'?

from pytr.

Katzmann1983 avatar Katzmann1983 commented on July 29, 2024

This issue should be fixed in the current master.

from pytr.

Related Issues (20)

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.