I need help with the code to stary binance futures userdata stream as the package is not working.
I tried following changes in the code but it failed stating that APIERROR(code=0) Invalid Jason
error message from Binance. The tweaks I made to subscribe futures userdatastream are as follows:
In my script:
bm = BinanceSocketManager(client)
def processmessage(msg):
print(msg)
conn_keys = bm.start_user_socket(processmsg)
bm.start()
In websockets.py
in def start_socket:
I replaced stream_url
with fstream_url
In client.py
in def create_api_uri:
I replaced api_url
with futures_url
I am in need of binance futures's userdata stream websockets.
I am also using the package as you.
What you need is to re-write the process_data logic to get the data, and then us the code as following:
bm.start_futures_socket(process_data)
bm.start()
I was also trying to do the same. I couldn't get python-binance to work, so I switched to the unicorn_binance_websocket_api .
Quick example:
from unicorn_binance_websocket_api.unicorn_binance_websocket_api_manager import BinanceWebSocketApiManager
binance_websocket_api_manager = BinanceWebSocketApiManager(exchange="binance.com-futures")
binance_websocket_api_manager.create_stream('arr', '!userData', api_key=<Your API key>, api_secret=<Your secret API key>, output="UnicornFy")
while True:
data = binance_websocket_api_manager.pop_stream_data_from_stream_buffer()
if data:
#do something with that data
pass
Maybe that helps.
this is my code:
binance = await AsyncClient.create(config.API_KEY, config.API_SECRET)
bsm = BinanceSocketManager(binance)
async with bsm.futures_multiplex_socket(streams) as ms:
while True:
msg = await ms.recv()
...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.