Giter VIP home page Giter VIP logo

Comments (17)

tmpccnt avatar tmpccnt commented on July 29, 2024 1

Short update:
I went into the rabbit hole to learn how to monitor websocket traffic - quite fun actually - and learned there is a new subscription command compactPortfolio, which returns a reduced json with only three entries:
{"positions":[{"instrumentId":"","netSize":"","averageBuyIn":""}]}
But that won't help with the old implementation, as a live update on the current net value is not provided.

from pytr.

miry avatar miry commented on July 29, 2024

I have the same. I think it is related to recent changes in Traderepublic like 2% of cash.

from pytr.

ChemicalEnginer avatar ChemicalEnginer commented on July 29, 2024

Same here. Worked last week but shows me the same error message

from pytr.

Jensener1 avatar Jensener1 commented on July 29, 2024

Short update: I went into the rabbit hole to learn how to monitor websocket traffic - quite fun actually - and learned there is a new subscription command compactPortfolio, which returns a reduced json with only three entries: {"positions":[{"instrumentId":"","netSize":"","averageBuyIn":""}]} But that won't help with the old implementation, as a live update on the current net value is not provided.

Do you have a list of all available subscription commands?

from pytr.

miry avatar miry commented on July 29, 2024

From Web TradeRepublic it seems to get detailed information per stock required to use type: instrument.

Example: sub 23 {"type":"instrument","id":"DE0001111111","jurisdiction":"DE"}

image

from pytr.

miry avatar miry commented on July 29, 2024

I pushed my changes to https://github.com/miry/pytr/tree/miry_master

$ git clone miry -b miry_master
$ pip3 install .
$ pytr -v debug portfolio

from pytr.

ChemicalEnginer avatar ChemicalEnginer commented on July 29, 2024

@miry With your changes the connection to websocket is possible again, thanks for that. There is a "bug", that the netValue of each position is 0, but you wrote in your code that is a ToDo. I'm curious for the next update.

from pytr.

miry avatar miry commented on July 29, 2024

@ChemicalEnginer I think Traderepublic removed old portfolio method becuase it is too big. They replaced it with small compactPortfolio. It requires to send additional request for each ISIN.

I will look next week for missing data.

from pytr.

miry avatar miry commented on July 29, 2024

@ChemicalEnginer Improved my changes and also add ability to show Title of the ISIN.

from pytr.

miry avatar miry commented on July 29, 2024

Sent PR: #39

from pytr.

GordonInDaHouse avatar GordonInDaHouse commented on July 29, 2024

Are there any news about it?

I am not using pytr, but another python tool, which has the same problem now. And I actually just need one value... the total depot amount.
I also had look on it today... and really got mad about their mess now.

My current thoughts about it.
'compactPortfolio' have 3 values:
instrumentId = Needs a separate call to get the details about the instrument.
netSize = How many do I owe.
averageBuyIn = How much did I spend on it. (In case someone wants to know the difference between current value and buy in price.)

So, the task is now to get the instrument data including the current price. Then we can multiply the netSize (which we have) with the current price and we have our personal amount for this instrument. And we have to repeat that with all instruments we have... add them up and we have the total value.

from pytr.

GordonInDaHouse avatar GordonInDaHouse commented on July 29, 2024

PS: I achieved my goal.

I'll share with you my code, maybe it is helpfull, even it is not straight for pytr (I work with https://github.com/Zarathustra2/TradeRepublicApi/).

tr = TrBlockingApi(NUMBER, PIN, locale="de")
tr.login()
TRcash = tr.available_cash()
cash = TRcash[0]["amount"]
TRportfolio = tr.compactPortfolio()
TotalValue = cash
for istrument in TRportfolio["positions"]:
    try:
        pp.pprint(istrument["instrumentId"])
        TRticker = tr.ticker(istrument["instrumentId"])

        print(TRticker["bid"]["price"])
        TotalValue += (istrument["netSize"] * TRticker["bid"]["price"])
        print("Value: " + str( (istrument["netSize"] * TRticker["bid"]["price"])))
        time.sleep(0.5)
    except Exception as err:
        print(f"Unexpected {err=}, {type(err)=}")

print("Total Value: " + str(TotalValue))

I did it like I said.
First I get the available Cash. There is a straight call for it.
Then I get the compact Portfolio and take the instrumentID (one by one) and call the the ticker api point with the isin. From there I receive the current ask and bit price. So I can multiply the netSize with the bid price. Sum everything up (with the cash value) and I have my total value.

Hope it helps a bit.

from pytr.

GordonInDaHouse avatar GordonInDaHouse commented on July 29, 2024

Hmm... I was a very happy man today in the morning. My depot value was 10 times higher than yesterday... :-)
Until I checked it in Trade Republic itself... nothing changed there :-( Not rich over night.

What happen?
The ticker request seems to be a websocket. So the requested data is not the data which will be received the next time a payload is coming in. Yesterday, by chance, it was like that. Today I request the ticker for the isin "DE1234" but the next payload from Trade Republic is the ticker for "US1234". Which is also in my portfolio, but still...

So I guess it is needed to use the websocket to collect first all ticker for all positions and then do the math (as far as I understood, this is the way the TR webapp is working). Or there is a way to really collect a single ticker, without websocket.

from pytr.

miry avatar miry commented on July 29, 2024

@GordonInDaHouse I have the same understanding. Previous portfolio operation did summarise for us. With a new implementation you need to collect all instruments and create a Total summaries.

In my PR https://github.com/marzzzello/pytr/pull/39/files#r1191328848 I have not work on it, first wanted to check that netValue is valid per single ISIN.

from pytr.

grafsen avatar grafsen commented on July 29, 2024

Hello,

Is there a new change in their api or did i make a mistake in the installation of pip?

2023-06-14 18:21:34+0200 main DEBUG logging is set to debug
2023-06-14 18:21:34+0200 account INFO Found credentials file
2023-06-14 18:21:34+0200 account INFO Phone: +49152********, PIN: ****
2023-06-14 18:21:34+0200 account INFO Web session resumed
2023-06-14 18:21:34+0200 account INFO Logged in
2023-06-14 18:21:34+0200 api INFO Connecting to websocket ...
2023-06-14 18:21:35+0200 api INFO Connected to websocket ...
2023-06-14 18:21:35+0200 api DEBUG Subscribing: 'sub 1 {"type": "portfolio"}'
2023-06-14 18:21:35+0200 api DEBUG Subscribing: 'sub 2 {"type": "cash"}'
2023-06-14 18:21:35+0200 api DEBUG Received message: '1 E {"errors":[{"errorCode":"BAD_SUBSCRIPTION_TYPE","errorField":null,"errorMessage":
"Unknown topic type","meta":{"source":"MAPPER"}}]}'

from pytr.

miry avatar miry commented on July 29, 2024

There is a change in TraderReublic API.
Fast fix is to install fork version: #37 (comment)

from pytr.

grafsen avatar grafsen commented on July 29, 2024

Yes, i know! It was my fault. I have make a mistake in the pip installation. Now the fix is working. Thanks for that :)

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.