Hi, I’m developing local order book handling and syncronizing with trade stream.
I faced next problem: if I subscribe to websocket streams independently it causes situation like this:
[info] Trade received tid=12560 system_timestamp: 1700525763583 ms
Trade: [Timestamp: 1700525763166 ms, price: 37486.6, quantity: 0.00064, is_buyer_maker: 0]
[info] Depth received tid=12560 system_timestamp: 1700525763596 ms
OrderBook: [Timestamp: 1700525763389 ms
[info] Trade received tid=12560 system_timestamp: 1700525763852 ms
Trade: [Timestamp: 1700525763166 ms, price: 37486.8, quantity: 0.10571, is_buyer_maker: 0]
So as you see trade which is recieved after diff_depth has binance timestamp later than previous diff_depth. And trades which have same binance timestamp 1700525763166 recieved with kind of big gap and what’s interesting after depth update.
If I’m using combined stream (e.g. /stream?streams=btcusdt@depth@100ms/btcusdt@trade) then it works fine(binance timestamps recieved in ascending order which is OK).
Could you hint me for my case if it could be expected that independent websocket streams (notice that process thread id is the same so no thread race) are going in wrong sequence?
And shall I use combined streams for my case?
So basically I’m asking if there’s guarantee that if I subscribe on multiple websocket streams for same trade pair, then data will come in the correct order(by event time sequence) or in my case it’s better to subscribe on multiple streams at one websocket(e.g. /stream?streams=btcusdt@depth@100ms/btcusdt@trade) so binance can handle the correct order on its own side?
Thanks