sammchardy / python-binance

Binance Exchange API python implementation for automated trading
https://python-binance.readthedocs.io/en/latest/
MIT License
5.98k stars 2.2k forks source link

start_futures_multiplex_socket Not Working #1034

Open ghost opened 2 years ago

ghost commented 2 years ago

Describe the bug start_futures_multiplex_socket is not working

My Code

from binance import Client, ThreadedWebsocketManager
from binance.enums import FuturesType

API_KEY    = "MY_API_KEY"
API_SECRET = "MY_API_SECRET"

client = Client(API_KEY,API_SECRET)

# # # socket manager using threads
twm = ThreadedWebsocketManager(API_KEY,API_SECRET)
twm.start()

def handle_socket_message(msg):
    print(msg)

stream_list = ["btcusdt@kline_1m", "ethusdt@kline_1m"]
twm.start_futures_multiplex_socket(callback=handle_socket_message,streams=stream_list,futures_type=FuturesType.USD_M)

# # # join the threaded managers to the main thread
twm.join()

Expected behavior working properly

Environment (please complete the following information):

renruojos commented 2 years ago

@mhasanjb Try change the streams to stream_list = ["btcusdt_perpetual@continuousKline_1m", "ethusdt_perpetual@continuousKline_1m"]

And for market data / kline socket, you don't need to authenticate. So you might want to just call ThreadedWebsocketManger() without parameters.

xiva-wgt commented 2 years ago

work with code websocket==9.1 and ThreadedWebsocketManager without auth `from binance import Client, ThreadedWebsocketManager from binance.enums import FuturesType

client = Client() twm = ThreadedWebsocketManager() twm.start()

def handle_socket_message(msg): print(msg)

stream_list = ["btcusdt@kline_1m", "ethusdt@kline_1m"] twm.start_futures_multiplex_socket(callback=handle_socket_message, streams=stream_list, futures_type=FuturesType.USD_M) twm.join()`