【发布时间】:2022-07-07 06:06:22
【问题描述】:
我正在尝试运行我在 jupyter notebook 上找到的教程中的以下代码:
from time import sleep
from binance import ThreadedWebsocketManager
btc_price = {'error':False}
def btc_trade_history(msg):
if (msg['e'] != 'error'):
print(msg['c'])
btc_price['last'] = msg['c']
btc_price['bid'] = msg['b']
btc_price['last'] = msg['a']
btc_price['error'] = False
else:
btc_price['error'] = True
bsm = ThreadedWebsocketManager()
bsm.start()
bsm.start_symbol_ticker_socket(callback=btc_trade_history, symbol='BTCUSDT')
这里是教程本身的链接:https://algotrading101.com/learn/binance-python-api-guide/
我猜,自从教程写好了,binance API 发生了一些变化,所以我得到了以下错误:
取消读取循环
从未检索到任务异常
未来:
请解释一下出了什么问题,我该如何解决?
【问题讨论】:
-
我也遇到了同样的问题,你找到解决办法了吗?
-
你有没有试过根据源码在
ThreadedWebsocketManager(api_key=..., api_secret=...)中提供api_key和api_secret? github.com/sammchardy/python-binance/blob/master/binance/…
标签: python python-asyncio binance-api-client