I hope you’re all doing well. I’m facing an issue while trying to get unPnL realtime in Futures.
With this document: Click here i see can using websocket with user data stream event to get realtime information but i don’t see any event to get unPnL realtime.
Is there any way?
Thank in advanced !
With the User Data Stream, there’s unfortunately no event for uPnL updates as it would put far too much strain on the connection as uPnL tends to change at least every second. You can use the User Data Stream to get realised profit, etc. For example, by using the
Event: Order Update, you’ll get updates whenever your order status changes (NEW, PARTIALLY_FILLED,FILLED,CANCELED,EXPIRED).
In order to get your uPnL, the best way is via the
GET /fapi/v2/account endpoint. This will return your
unrealizedProfit for each relevant asset and position.
Thank for reply. With the
GET /fapi/v2/account endpoint we can get PnL but if using request so much, my ip can be block. I was blocked before. Is there a way to safely use it on my server? My server currently has many users, they need to get each person’s PnL
GET /fapi/v2/account endpoint has a Weight of 5. What this means is that each request made to it counts for 5 normal API calls. There is a request weight limit of 1,200 per minute. 1200 / 5 = maximum of 240 requests per min (1200 limit / 5 weight).
You can refer to this FAQ Page for more information about Rate Limits, etc.
Hope that helps.