[英]Python-binance futures user data websocket
I need help with the code to stary binance futures userdata stream as the package is not working.由于 package 不工作,我需要代码来帮助我解决问题。
I tried following changes in the code but it failed stating that APIERROR(code=0) Invalid Jason
error message from Binance.我尝试对代码进行以下更改,但它未能说明来自 Binance 的
APIERROR(code=0) Invalid Jason
错误消息。 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
在
def start_socket:
的websockets.py
中:我用stream_url
替换了fstream_url
In client.py
in def create_api_uri:
I replaced api_url
with futures_url
在
def create_api_uri:
的client.py
中:我用api_url
替换了futures_url
I am in need of binance futures's userdata stream websockets.我需要币安期货的用户数据 stream websockets。
I am also using the package as you.我也像你一样使用 package。
What you need is to re-write the process_data logic to get the data, and then us the code as following:您需要重新编写 process_data 逻辑以获取数据,然后我们的代码如下:
bm.start_futures_socket(process_data) bm.start_futures_socket(process_data)
bm.start() 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 .
我无法让 python-binance 工作,所以我切换到了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()
...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.