Hello,
I am working with future APIs.
I was wondering if it was possible to retrieve the PnL and the margin ratio on a current position via websocket streaming?
If it’s not possible, the only way to get it would be to get the price of the asset in parallel and calculate locally the PnL with the entry price of our position, right?
I’m currently using this stream :
But I receive messages only when a new position is added, or when a position is closed. I also expected to receive messages about the PnL update as well.
Yes I am aware that it is possible to retrieve this information via the REST api, but the ideal in my case would have been via websocket. I need to display this information on a web platform, the user must be able to see in real time his gains and losses.
I don’t think calling the endpoint via the REST api every second is the ideal solution, so I think I just have to calculate all this information locally, right?
For example, if the user is in a BTC/USDT position, I have to subscribe via websocket and get the market price updates, then get the entry price of the current position, and calculate the PnL with these two variables. Do you see a better alternative?
Thank you very much
As specified above I did it like this:
“For example, if the user have a BTC/USDT position, I have to subscribe via websocket and get the market price updates, then get the entry price of the current position, and calculate the PnL with these two variables”