kucoin-api-docs
kucoin-api-docs copied to clipboard
Correct procedure for Level-2 market data calibration
Hi,
https://docs.kucoin.com/#level-2-market-data contains:
Calibration procedure:
- After receiving the websocket Level 2 data flow, cache the data.
- Initiate a REST request to get the snapshot data of Level 2 order book.
- Playback the cached Level 2 data flow.
- Apply the new Level 2 data flow to the local snapshot to ensure that the sequence of the new Level 2 update lines up with the sequence of the previous Level 2 data. Discard all the message prior to that sequence, and then playback the change to snapshot.
- Update the level2 full data based on sequence according to the price and size. If the price is 0, ignore the messages and update the sequence. If the size=0, update the sequence and remove the price of which the size is 0 out of level 2. For other cases, please update the price.
I'm not sure how to correctly proceed in step 3 and 5 as the example JSON update message in the docs does not help me:
{
"type":"message",
"topic":"/market/level2:BTC-USDT",
"subject":"trade.l2update",
"data":{
"sequenceStart":1545896669105,
"sequenceEnd":1545896669106,
"symbol":"BTC-USDT",
"changes":{
"asks":[["6","1","1545896669105"]], //price, size, sequence
"bids":[["4","1","1545896669106"]]
}
}
}
My questions are:
- Are
changes.asks(in the JSON above) andchanges.bidssorted by price or by sequence numbers or not sorted at all? - Can I apply updates in
changesforasksfirst and then forbids? Or do I need to mergechanges.asksandchanges.bids, sort by sequence numbers and apply update change after another? - Is there any sample how to correctly implement the calibration procedure mentioned in https://docs.kucoin.com/#level-2-market-data?
Thank you!
Hi
- They are stored with sequence number
- you can apply update one after another
- we are making one. I will post it on Leraning Center channel
where you able to solve this problem?