hello.
I would like to receive symbols of multiple spots via websocket stream.
As I understand it, biannce is providing the orderbook of future market using websocket with timestamp.
But the orderbook of SPOT market does not provide timestamp.
It is very important to see the timestamp to check the time delay. However, it seems difficult to check the timestamp of spot using partial-book-detph websocket at the moment.
I think a possible way is to use spot’s diff-depth-stream to get the real-time orderbook and get the timestamp at the same time.
I would like to ask if anyone has a good example of the above method?
Or is there any way to get the spot orderbook via websocket stream with timestamp?
Thanks in advance.
Using the diff-depth stream for the spot market is a viable solution, as it provides both the last update ID and the event time, which can serve as a timestamp indicating when the last change occurred.
Python example using the websocket-client library to subscribe to the diff-depth stream for a specific symbol (e.g., btcusdt). This example prints the order book updates along with the timestamps:
import websocket
import json
def on_message(ws, message):
data = json.loads(message)
print(“Timestamp:”, data[‘E’]) # Event time
print(“Last Update ID:”, data[‘u’]) # Last update ID of the order book
print(“Bids:”, data[‘b’]) # List of all bids
print(“Asks:”, data[‘a’]) # List of all asks
print(“----”)