Closed salian closed 3 years ago
Indeed it was my misunderstanding that all Binance endpoints are reasonably alike. $all@allTickers
is not available on binance.com exchange. It's only available for dex (binance.org) exchange.
As per https://binance-docs.github.io/apidocs/spot/en/#all-market-tickers-stream the alternative equivalent for websocket stream with every-second updates on 24hr rolling window ticker statistics for all symbols is !ticker@arr
For the sake of anyone who finds this thread, a working example for all tickers would be
from unicorn_binance_websocket_api.unicorn_binance_websocket_api_manager import BinanceWebSocketApiManager
def run_main_loop():
binance_websocket_api_manager = BinanceWebSocketApiManager(exchange="binance.com")
binance_websocket_api_manager.create_stream('arr', '!ticker')
while True:
oldest_stream_data_from_stream_buffer = binance_websocket_api_manager.pop_stream_data_from_stream_buffer()
if oldest_stream_data_from_stream_buffer:
print(oldest_stream_data_from_stream_buffer)
if __name__ == "__main__":
run_main_loop()
When I use
BinanceWebSocketApiManager
with binance.com exchange and$all@allTickers
I get HTTP error 400 Bad Request.But the same code works fine with binance.org and returns data on websocket.
The debug log: