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_kline_socket` fails quietly if `interval` argument is set wrong #1193

Closed mikkokotila closed 2 years ago

mikkokotila commented 2 years ago

Describe the bug If the interval argument is set wrong (e.g. 1s) then everything seems to run fine, but there is no data coming in.

To Reproduce

f = open('test.csv', 'a')

stream = ThreadedWebsocketManager(api_key=api_key, api_secret=api_secret)

stream.start()

def handle_socket_message(msg):
        f.write('test.csv')

stream.start_kline_socket(callback=handle_socket_message, symbol=symbol, interval='1s')

stream.join()

Expected behavior Should throw an exception/error instead of failing silently.

Environment (please complete the following information):

halfelf commented 2 years ago

Websocket is not like http, for binance just has not implemented a 404 for path not found. This is an expected behavior.

One can check this behavior by connect to wss://stream.binance.com:9443/ws/nonsense_path.

For users, it should be safe to use all the enums defined in this SDK instead of string or numeric literals.

mikkokotila commented 2 years ago

Thanks for clarifying, I anticipated that this was due to the way in which Binance handles it (well in this case doesn't handle it).