From 732b6606ac092770f262e68fa9560fd51601614f Mon Sep 17 00:00:00 2001 From: msincenselee Date: Sat, 6 Jun 2020 16:11:55 +0800 Subject: [PATCH] =?UTF-8?q?[bug=20fix]=20=E4=BF=AE=E5=A4=8D=E8=BD=AE?= =?UTF-8?q?=E8=AF=A2=E8=B4=A6=E5=8F=B7=E3=80=81=E6=8C=81=E4=BB=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vnpy/gateway/binance/binance_gateway.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/vnpy/gateway/binance/binance_gateway.py b/vnpy/gateway/binance/binance_gateway.py index 896c0ee2..e0144707 100644 --- a/vnpy/gateway/binance/binance_gateway.py +++ b/vnpy/gateway/binance/binance_gateway.py @@ -102,7 +102,7 @@ class BinanceGateway(BaseGateway): def __init__(self, event_engine, gateway_name="BINANCE"): """Constructor""" super().__init__(event_engine, gateway_name) - + self.count = 0 self.trade_ws_api = BinanceTradeWebsocketApi(self) self.market_ws_api = BinanceDataWebsocketApi(self) self.rest_api = BinanceRestApi(self) @@ -159,6 +159,14 @@ class BinanceGateway(BaseGateway): and self.status.get('mdws_con', False): self.status.update({'con': True}) + self.count += 1 + if self.count < 2: + return + self.count = 0 + if len(self.query_functions) > 0: + func = self.query_functions.pop(0) + func() + self.query_functions.append(func) class BinanceRestApi(RestClient): """ @@ -268,6 +276,9 @@ class BinanceRestApi(RestClient): self.query_contract() self.start_user_stream() + # 添加到定时查询队列中 + self.gateway.query_functions = [self.query_account] + def query_time(self): """""" data = { @@ -346,6 +357,10 @@ class BinanceRestApi(RestClient): "newOrderRespType": "ACK" } + if req.type == OrderType.MARKET: + params.pop('timeInForce', None) + params.pop('price', None) + self.add_request( method="POST", path="/api/v3/order",