Task 2. User Stream Tracker¶
UserStreamTracker responsibility is to fetch user account data and queues it accordingly.
UserStreamTracker contains subsidiary classes that help maintain the real-time wallet/holdings balance and open orders of a user. Namely, the classes required are:
This is only required in Centralized Exchanges.
UserStreamTrackerDataSource class is responsible for initializing a WebSocket connection to obtain user related trade and balances updates.
Integrating your own data source component would require you to extend from the UserStreamTrackerDataSource base class here.
The table below details the required functions in
|Function||Input Parameter(s)||Expected Output(s)||Description|
||Should be updated(using python's time.time()) everytime a message is received from the websocket.|
|None||Subscribe to user stream via web socket, and keep the connection open for incoming messages|
UserStreamTracker class is responsible for maintaining the real-time account balances and orders of the user.
This can be achieved in 2 ways(depending on the available API on the exchange):
In this scenario, we would have to periodically make API requests to the exchange to retrieve information on the user's account balances and order statuses. An example of this can be seen in Huobi's connector market file connector. The market file shows that Huobi uses REST API alone by periodically calling the market's
_status_polling_loop(). Also, it can be seen that no user stream files exist in Huobi's connector directory.
When an exchange does have WebSocket API support to retrieve user account details and order statuses, it would be ideal to incorporate it into the Hummingbot client when managing account balances and updating order statuses. This is especially important since Hummingbot needs to knows the available account balances and order statuses at all times.
The table below details the required functions to be implemented in
|Function||Input Parameter(s)||Expected Output(s)(s)||Description|
||Initializes a user stream data source.|
||None||None||Starts all listeners and tasks.|
||Returns the message queue containing all the messages pertaining to user account balances and order statues.|