Create USDM Futures and Spot bookTicker Websockets

PHOTO EMBED

Tue Jun 01 2021 17:55:37 GMT+0000 (Coordinated Universal Time)

Saved by @alexjnelson #python #binance #python-binance

symbols = ['BTCUSDT', 'ETHUSDT']

twm = ThreadedWebsocketManager()
twm.start()

twm.start_multiplex_socket(callback=lambda msg: print('Spot:', msg), streams=[f'{s.lower()}@bookTicker' for s in symbols])
twm.start_futures_multiplex_socket(callback=lambda msg: print('Futures:', msg), streams=[f'{s.lower()}@bookTicker' for s in symbols])
content_copyCOPY