Dear API user,
Currently, the websocket subscription topic ‘market.$symbol.mbp.$levels’ only supports 150 levels MBP book, and the update is based on the gap between two snapshots at 100ms interval.
Since the effective day of this notification, in addition to existing 150-level MBP book, the topic will also support 5-level MBP book, in tick by tick mode. It means, whenever the certain-level MBP book being changed (price or size), the topic will send the incremental update to downstream.
At the same time, API user should be able to get refresh update of certain-level MBP book, based on a REQ request to the same websocket channel. And inside the refresh message, seqNum is in line with incremental message from the subscription topic.
5-level tick by tick MBP feed (including both SUB channel and REQ channel) is only available at following URLs –
At this stage, only following 9 currency pairs are supported by 5-level tick by tick MBP feed –
The subscription details and the data processing logic should keep same as existing. API user just needs to define the parameter ‘levels’ in order to subscribe desired market depth. Of course before processing incremental data, API user should request for refresh image first and align the seqNum.
The differences between 5 levels incremental MBP feed and 150 levels incremental MBP feed:
1) Different depth of market.
2) 5 levels incremental MBP is a tick by tick feed, which means whenever there is an order book change at that level, it pushes an update; 150 levels incremental MBP feed is based on the gap between two snapshots at 100ms interval.
3) While there is single side order book update, either bid or ask, the incremental message sent from 5 levels MBP feed only contains that side update. But the incremental message from 150 levels MBP feed contains not only that side update and also a blank object for another side.
4) While there is nothing change between two snapshots in past 100ms, the 150 levels incremental MBP feed still sends out a message which containing two blank objects – bids & asks. But as the 5 levels incremental MBP is a tick by tick feed, it won’t disseminate any update in such a case.
Market By Price (incremental update)
User could subscribe to this channel to receive incremental update of Market By Price order book. Refresh message, the full image of the order book, is acquirable from the same channel, upon "req" request.
Suggested downstream data processing:
1. Subscribe incremental updates and start to cache them;
2. Request refresh message (with same number of levels), and base on its “seqNum” to align it with the cached incremental message which having a same “prevSeqNum”;
3. Start to continuously process incremental messages to build up MBP book;
4. The “prevSeqNum” of current incremental message must be same with “seqNum” of previous message, otherwise it implicates message loss which should require another round refresh message retrieval and alignment;
5. Once receiving a new price level from incremental message, that price level should be inserted into appropriate position of existing MBP book;
6. Once receiving an updated “size” at existing price level from incremental message, the level size should be replaced directly by the new value;
7. Once receiving a “size=0” at existing price level from incremental message, that price level should be removed from MBP book;
8. If one incremental message includes updates of multiple price levels, all of those levels should be updated simultaneously in MBP book.
Subscribe incremntal updates
Request refresh update
|Field Name||Data Type||Mandatory||Default Value||Description||Value Range|
|symbol||string||true||NA||Trading symbol (wildcard inacceptable)|
|levels||integer||true||NA||Number of price levels||5,150|
- 5-level MBP feed is updating in tick by tick mode.
- 150-level MBP feed is updating in snapshot mode at 100ms interval.
Response (Incremental update subscription)
"ts": 1489474081631 //system response time
Incremental Update (Incremental update subscription)
"ts": 1573199608679, //system update time
[645.140000000000000000, 26.755973959140651643] // [price, size]
Response (Refresh update acquisition)
[618.37, 71.594], // [price, size]
|Field Name||Data Type||Description|
|seqNum||integer||Sequence number of the message|
|prevSeqNum||integer||Sequence number of previous message|
|bids||object||Bid side, (in descending order of “price”), ["price","size"]|
|asks||object||Ask side, (in ascending order of “price”), ["price","size"]|
What are the Impacts on You, and What You Need to Do?
API users should evaluate the business impact caused by the enhancement, further to make relevant change in client’s application, if needed.
All the changes will be updated on Huobi API Docs on the effective date.
Article is closed for comments.