I’m running trading bot for futures and I’d like to ask one question.
The bot is using both user_data_stream websocket and the rest api((fapi/v1/positionRisk) for the position update. The user_data_stream is mainly used for managing the current position and the rest api is used as a fallback in case where position update notification is lost due to connectivity issue, e.g. connection hiccup.
The issue is that I’m getting old position size via the rest api after receiving the position update from user_data_stream. It seems that there’s some delay for the position update when calling the rest api.
- can you tell me how long the delay may be?
- what’s the best way to get the current position size in case where the position update is lost?
FYI, here’s the logs: