Does anyone know what is the latest Binance API function version of start_multiplex_socket,
start_user_socket, start_symbol_ticker_socket or similar from
BinanceSocketManager or another module to start socket connexion.
For transparency, I am the programmer of the UNICORN Binance Suite and would like to present my solutions!
Here is a full script for a multiplex stream:
from unicorn_binance_websocket_api import BinanceWebSocketApiManager
import asyncio
async def main():
async def process_asyncio_queue(stream_id=None):
print(f"Start processing the data from stream '{ubwa.get_stream_label(stream_id)}':")
while ubwa.is_stop_request(stream_id) is False:
data = await ubwa.get_stream_data_from_asyncio_queue(stream_id)
print(data)
ubwa.asyncio_queue_task_done(stream_id)
ubwa.create_stream(channels=['trade', 'kline_1m'],
markets=['ethbtc', 'btcusdt'],
stream_label="MULTIPLEX",
process_asyncio_queue=process_asyncio_queue)
while not ubwa.is_manager_stopping():
await asyncio.sleep(1)
with BinanceWebSocketApiManager(exchange='binance.com') as ubwa:
try:
asyncio.run(main())
except KeyboardInterrupt:
print("\r\nGracefully stopping ...")
except Exception as e:
print(f"\r\nERROR: {e}\r\nGracefully stopping ...")
once I launch my strategy bot my terminal displays this : APIError(code=-1121): Invalid symbol :
Traceback (most recent call last):
File “/Users/brandonmbambi/Documents/BOT/bot280524/BOT.py”, line 134, in
main()
File “/Users/brandonmbambi/Documents/BOT/bot280524/BOT.py”, line 91, in main
set_leverage(symbol, leverage)
File “/Users/brandonmbambi/Documents/BOT/bot280524/BOT.py”, line 42, in set_leverage
client.futures_change_leverage(symbol=symbol, leverage=leverage)
File “/Users/brandonmbambi/trading_bot_env/lib/python3.12/site-packages/binance/client.py”, line 6590, in futures_change_leverage
return self._request_futures_api(‘post’, ‘leverage’, True, data=params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/Users/brandonmbambi/trading_bot_env/lib/python3.12/site-packages/binance/client.py”, line 383, in _request_futures_api
return self._request(method, uri, signed, True, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/Users/brandonmbambi/trading_bot_env/lib/python3.12/site-packages/binance/client.py”, line 359, in _request
return self._handle_response(self.response)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/Users/brandonmbambi/trading_bot_env/lib/python3.12/site-packages/binance/client.py”, line 368, in _handle_response
raise BinanceAPIException(response, response.status_code, response.text)
binance.exceptions.BinanceAPIException: APIError(code=-1121): Invalid symbol.
(trading_bot_env) brandonmbambi@MacBook-Pro-3 ~ %