Python-binance: Websocket Account Update

Created on 2 May 2018  路  4Comments  路  Source: sammchardy/python-binance

Hello,

I've noticed that there isn't a websocket stream similar to

info = client.get_account()

Basically I want a constant update on available Asset Balances but the API takes to much time.

In the official API docs i found a user data stream;
https://github.com/binance-exchange/binance-official-api-docs/blob/master/user-data-stream.md
It is called the outboundAccountInfo

Since I am not that familiar with API wrappers, how can I implement this stream? What has to be considered?

regards

Most helpful comment

I'm not sure what you mean by risking time. You can start the websocket first, then initialize the balances through the REST API, then update it whenever you get an update through the socket, which happens within a split second of an order fill. All updates, including the REST API result, are timestamped, so you can always know which result is more fresh (e.g. if you get a websocket response after you sent the REST API request but before the response arrived.)

All 4 comments

It's the user socket. It doesn't return anything until something changes (so you gotta use get_account at least once), but then it returns both the change (e.g. a placed or cancelled or filled order) and then also your account info (same as get_account, but with one-letter shortened keys) which includes the now updated balances, both free and locked.

I see so there is no other way to get my asset balances without risking time.
Thanks for clearing that up!

I'm not sure what you mean by risking time. You can start the websocket first, then initialize the balances through the REST API, then update it whenever you get an update through the socket, which happens within a split second of an order fill. All updates, including the REST API result, are timestamped, so you can always know which result is more fresh (e.g. if you get a websocket response after you sent the REST API request but before the response arrived.)

alright will try that thanks !

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rightx2 picture rightx2  路  4Comments

echel0n picture echel0n  路  4Comments

ayy1337 picture ayy1337  路  6Comments

fj317 picture fj317  路  6Comments

ohsnapitsjojo picture ohsnapitsjojo  路  3Comments