vnpy_binance
vnpy_binance copied to clipboard
订阅行情之后会断流
GATEWAY:BINANCE_SPOT
订阅之后几个小时以后会断流,原因不明。(大概4个小时?)
断流之后就不会再收到更新了,暂时不清楚是不是币安的限制还是纯粹的网络问题。
但不管是哪个,之后也无法恢复。
暂时找到的办法只有先清掉market_ws_api.ticks,再重新订阅一次。
main_engine.get_gateway("BINANCE_SPOT").market_ws_api.ticks.pop("ethbtc")
I met the exact same question for the BINANCE-USDT gateway. What's the problem do you think?
I met the exact same question for the BINANCE-USDT gateway. What's the problem do youat think?
I don't know how this happened. After several tries, I found that it happened at different length of time, which means this may just be a websocket disconnected problem and vnpy_binance did not handle it (for example reconnect).
Now I use a workaround, check if last_tick timestamp is behind currerent time 20 seconds, pop symbols and re-subscript it.
main_engine.get_gateway("BINANCE_SPOT").market_ws_api.ticks.pop("ethbtc")
It works fine, for now.
will check on this later
@Zigngit 刚刚开始基于VNPY做策略,也遇到了同样的断流问题,您的临时解决方案具体是怎么修改的,可以分享个demo给我吗?万分感谢!
will check on this later
The reason for this problem is binance’s api work wron.
the api even you call it within an hour,the listenKey stil will become invalid.
this is my solution。
this api said
If the account has an active listenKey, that listenKey will be returned and its validity will be extended for 60 minutes.
,but is worng,the listenKey still will be change,you hava to reset it.
@xuxin3101 @vn-crypto I don't think the problem comes here. I think the fundamental problem comes from the break of the trade/market data websocket. It may be the network problem of your own trading server even if you are using AWS or AlibabaClound. I think the ultimate solution is to monitor the connection of the trade/market data websocket. Whenever the websocket breaks, the gateway should reconnect it as soon as possible.
@Zigngit @xyxido @xuxin3101 @vn-crypto 我们一起建立个关于币安接口的微信群如何? CoolQuant, 这个是我的微信号,大家有兴趣的话加我一下,平时遇到的币安接口问题我们可以及时在群里沟通。
How about this solution?
will check on this later
The reason for this problem is binance’s api work wron.
the api even you call it within an hour,the listenKey stil will become invalid.
this is my solution。
this api said
If the account has an active listenKey, that listenKey will be returned and its validity will be extended for 60 minutes.
,but is worng,the listenKey still will be change,you hava to reset it.
@xuxin3101 我实测了一下listenkey,发现一两个小时之内断开后重连,短时间内的listenkey都是不变的,并没有发现每次延迟listenkey就发生变化的情况啊,请问你是怎么发现延长后的listenkey变化了呢?