What is the problem we try to solve?
We want to know the best bid/ask price before and after a trade occurred.
What we tried?
We consumed the websocket<symbol>@bookTicker
and <symbol>@trade
events. In our expectation/understatement, combining the 2 stream eg. ?streams=bnbusdt@bookTicker/bnbusdt@trade
does NOT guarantee event orders as they may be asynchronous code that merges the 2 underlying streams.
We thought about using timestamps from the 2 underlying event streams to get a best effort sync between the two. Best effort as we consider that there are different systems that (1) maintain book that emit book ticker and (2) match trades that emit trade events. But unfortunately bookTicker
lacks of any timestamp data.
Again timestamps could introduce errors as the timestamps wont be generated from the exact same clock, but it should be better (more close to reality) than relying on timestamp on the event arrived on our (client) side.
We understand that adding more values to events means sacrifice of performance but feel that timestamp is on the values that could really help this case other cases.
Could we introduce event timestamp in bookTicker
? If this is not “possible” what are the workarounds to solve our problem?
Thanks in advance