Is any way to get OrderBook snapshot by ws-methods?
Georim opened this issue · comments
Hello.
Using that library (method "onUpdateExchangeState") I subscribe to a market(for example: "BTC-BCC") and obtain updates of order book with id (nounce).
But, usually exchanges have sent snapshot of all orderBook before they start to send updates.
For example cex.io: https://cex.io/websocket-api-dsl
/-----------------------------------------------------------------------------------------------/
Incremental version id:
- is to be used to build client presentation of order book
- firstly, id is returned in the response with a snapshot of order book
- then, server is sending incremental updates (Market data update), id is incremented by 1 with each update
- suggested approach to build order-book locally is following:
- request snapshot with subscription and start collecting updates;
- when snapshot received, increment collected updates, starting from the id, next to the id in snapshot received;
- if one update is missed, the client presentation of order-book becomes inconsistent
/-----------------------------------------------------------------------------------------------/
Without initial orderBook snapshot you have no guarantee that orderBook that you have constructed by updates is consistent.
@CCob may be do you know any method to obtain orderBookSnapshot by ws-connection?
I have tried to use orderBookSnapshot obtaining by REST-request. But unfortunately that snapshot isn't consistent with updates.
Yes, after you have registered for order book snapshots you need to call queryExchangeState
. This will give you the order book snapshot along with a nonce, then you apply all onUpdateExchange
state nonces sequentially. It will return max 500 order book entries though. Also don't call this in a tight look as it's intensive and bittrex will ban you IP