With python-binance 1.0.17, after upgrading from python 3.9.0 to 3.11.3 I've an error message when opening a socket
File "C:\PLDesign\scalp_asyncio\trader.py", line 988, in open_socket
self.bsm = BinanceSocketManager(self.client)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python311\Lib\site-packages\binance\streams.py", line 317, in __init__
self.STREAM_URL = self.STREAM_URL.format(client.tld)
^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'tld'
which is because the client could not be created.
The AsyncClient.create() returns the error
startTimer(self, interval: int, timerType: Qt.TimerType = Qt.CoarseTimer): argument 1 has unexpected type 'float'
To Reproduce
To create the client my code is:
async def open_client(self):
try:
self.client = await AsyncClient.create(api_key, api_secret, tld='com')
except Exception as e:
logging.error(f'### ERROR while creating the client, msg= {e}')
await self.handle_error(e)
return
To open a websocket:
async def open_socket(self):
if self.websocket:
logging.info('Websocket already opened...')
return
try:
# Create the websocket manager
self.bsm = BinanceSocketManager(self.client)
# Open the websocket
if self.socket_type == "TRADE":
self.websocket = self.bsm.trade_socket(self.symbol)
elif self.socket_type == "KLINE":
self.websocket = self.bsm.kline_socket(self.symbol)
elif self.socket_type == "MULTIPLEX_KLINE" or self.socket_type == "MULTIPLEX_TICKER":
self.websocket = self.bsm.multiplex_socket(self.stream_list)
# wait for message reception and emit signal to connect the message processing callback
self.is_websocket_closed = False
async with self.websocket as ws:
while not self.should_stop:
message = await ws.recv()
self.new_data.emit(message) # send a signal to connect to the message processing callback
except websockets.exceptions.ConnectionClosed as e:
logging.error(f'{self.socket_type}: WebSocket closed: ', e)
await self.close_socket()
except asyncio.CancelledError:
logging.error(f'{self.socket_type}: Websocket Task Cancelled')
await self.close_socket()
except asyncio.TimeoutError:
logging.error(f'{self.socket_type}: Asyncio timeout error')
await self.close_socket()
except (BinanceRequestException, BinanceAPIException, Exception) as e:
logging.error(f'{self.socket_type}: WebSocket error: ', e)
await self.close_socket()
finally:
await self.close_socket()
Expected behavior
This work with Python 3.9.0 despite I've some troubles to stabilize the communication error management.
With Python 3.11.3 the code crashes as soon as I'm trying to open the socket with the error listed above.
Environment (please complete the following information):
Python version: 3.9.0 & 3.11.3
Virtual Env: either from commande line or using pycharm with venv
With python-binance 1.0.17, after upgrading from python 3.9.0 to 3.11.3 I've an error message when opening a socket
which is because the client could not be created. The AsyncClient.create() returns the error
startTimer(self, interval: int, timerType: Qt.TimerType = Qt.CoarseTimer): argument 1 has unexpected type 'float'
To Reproduce To create the client my code is:
To open a websocket:
Expected behavior This work with Python 3.9.0 despite I've some troubles to stabilize the communication error management. With Python 3.11.3 the code crashes as soon as I'm trying to open the socket with the error listed above.
Environment (please complete the following information):