[英]Python-binance futures user data websocket
由於 package 不工作,我需要代碼來幫助我解決問題。
我嘗試對代碼進行以下更改,但它未能說明來自 Binance 的APIERROR(code=0) Invalid Jason
錯誤消息。 我為訂閱期貨用戶數據流所做的調整如下:
在我的腳本中:
bm = BinanceSocketManager(client)
def processmessage(msg):
print(msg)
conn_keys = bm.start_user_socket(processmsg)
bm.start()
在def start_socket:
的websockets.py
中:我用stream_url
替換了fstream_url
在def create_api_uri:
的client.py
中:我用api_url
替換了futures_url
我需要幣安期貨的用戶數據 stream websockets。
我也像你一樣使用 package。
您需要重新編寫 process_data 邏輯以獲取數據,然后我們的代碼如下:
bm.start_futures_socket(process_data)
bm.start()
我也試圖做同樣的事情。 我無法讓 python-binance 工作,所以我切換到了unicorn_binance_websocket_api 。
快速示例:
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
也許這有幫助。
這是我的代碼:
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.