Thanks for the reply, Dino, but it doesn’t quite answer my question.
The ACCOUNT_UPDATE event emits the wallet balance and the cross wallet balance. These balances may or may not indicate how much is available to be withdrawn/traded. The REST endpoint has the additional fields availableBalance and maxWithdrawAmount.
What I want to know is whether the cross wallet balance can be used as a proxy for the availableBalance or maxWithdrawAmount when trading exclusively with isolated positions?
I should probably use this opportunity to request that you add the available/maxWithdrawAmount to the websocket event.
There is no point in sending transmitting the available balance with the ACCOUNT_UPDATE event, because the available balance is changing all the time, because of changing unrealized PNL.
However I have the same problem. I want to calculate available balance from data that I get from the stream.
What I get is in the range of the available balance that I get from a REST API request, or from the website. But it is never really correct. Why? I tried to use the latest price, the index price and the mark price for the calculation, same problem.
The unrealized_pnl calculation returns exactly the same values as the website and REST API, updated every 3 seconds. But my available_balance calculation is off. Why?