您好,我想用Websocket方式获取BTC/JPY现货交易对的K线数据,但是无返回信息,是参数有错误还是没开放该交易对,以下是订阅函数。谢谢!
params = “btcjpy@kline_1m”
def on_open(ws):
subscribe_message = {
“method”: “SUBSCRIBE”,
“params”: [params],
“id”: 1
}
ws.send(json.dumps(subscribe_message))
我在cmd上使用websocat 是能收到信息的,你看看是不是你代码哪里有写错了不。
aisling$ websocat -v "wss://stream.binance.com:9443/ws/btcjpy@kline_1d"
[INFO websocat::lints] Auto-inserting the line mode
[INFO websocat::stdio_threaded_peer] get_stdio_peer (threaded)
[INFO websocat::ws_client_peer] get_ws_client_peer
[INFO websocat::ws_client_peer] Connected to ws
{"e":"kline","E":1716969097863,"s":"BTCJPY","k":{"t":1716940800000,"T":1717027199999,"s":"BTCJPY","i":"1d","f":453290,"L":455960,"o":"10773471.00000000","c":"10745368.00000000","h":"10895000.00000000","l":"10740000.00000000","v":"9.27618400","n":2671,"x":false,"q":"100393684.35115200","V":"4.60186400","Q":"49810973.51413700","B":"0"}}