0xffff
December 24, 2021, 7:35am
1
Why <symbol>@bookTicker
does’t has e
(event) field?
Just like <symbol>@trade
{
"e": "trade", // 事件类型
"E": 123456789, // 事件时间
"s": "BNBBTC", // 交易对
"t": 12345, // 交易ID
"p": "0.001", // 成交价格
"q": "100", // 成交数量
"b": 88, // 买方的订单ID
"a": 50, // 卖方的订单ID
"T": 123456785, // 成交时间
"m": true, // 买方是否是做市方。如true,则此次成交是一个主动卖出单,否则是一个主动买入单。
"M": true // 请忽略该字段
}
Can add it like this?
{
"e": "bookTicker",
"u":400900217, // order book updateId
"s":"BNBUSDT", // 交易对
"b":"25.35190000", // 买单最优挂单价格
"B":"31.21000000", // 买单最优挂单数量
"a":"25.36520000", // 卖单最优挂单价格
"A":"40.66000000" // 卖单最优挂单数量
}
Thanks for the suggestion. The team is aware of this request.
The tickers do not include the e
and E
properties to reduce the message size and improve performance for the server and client due to the high frequency of messages.
If structure is a higher priority over performance, the property e
can be extracted from the stream name when using the multi-stream websocket url.
wss://stream.binance.com:9443/stream?streams=btcusdt@bookTicker
{
"stream": "btcusdt@bookTicker", # Extract stream type
"data": {
"u": 16376202896,
"s": "BTCUSDT",
"b": "41801.93000000",
"B": "0.04953000",
"a": "41801.94000000",
"A": "2.13369000"
}
}
cosmo
April 9, 2022, 8:04am
7
I have a question. If the bookTicker stream did not have event time, how could i to make sure the latency if i subscribe lots of topic in one connection?
@cosmo It’s not possible to determine latency using the bookTicker stream.
Its a workaround but this lib can help you: GitHub - LUCIT-Systems-and-Development/unicorn-fy: Convert received raw data from crypto exchange API endpoints into well-formed python dictionaries.
{"stream":"btcusdt@aggTrade","data":{"e":"aggTrade","E":1592584651517,"s":"BTCUSDT","a":315753210,"p":"9319.00000000","q":"0.01864900","f":343675554,"l":343675554,"T":1592584651516,"m":true,"M":true}
becomes
{'stream_type': 'btcusdt@aggTrade', 'event_type': 'aggTrade', 'event_time': 1592584651517, 'symbol': 'BTCUSDT', 'aggregate_trade_id': 315753210, 'price': '9319.00000000', 'quantity': '0.01864900', 'first_trade_id': 343675554, 'last_trade_id': 343675554, 'trade_time': 1592584651516, 'is_market_maker': True, 'ignore': True}`