From 148873e3e8523a4c13410a99098bbe84ba4c343d Mon Sep 17 00:00:00 2001 From: noranhe <63988546+noranhe@users.noreply.github.com> Date: Sat, 8 May 2021 18:23:22 +0800 Subject: [PATCH 1/2] Update okex_gateway.py --- vnpy_okex/okex_gateway.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/vnpy_okex/okex_gateway.py b/vnpy_okex/okex_gateway.py index b280a1a..a31b852 100644 --- a/vnpy_okex/okex_gateway.py +++ b/vnpy_okex/okex_gateway.py @@ -705,7 +705,7 @@ def on_login(self, packet: dict) -> None: def on_order(self, packet: dict) -> None: """委托更新推送""" - data = packet["data"] + data: list = packet["data"] for d in data: order: OrderData = parse_order_data(d, self.gateway_name) self.gateway.on_order(order) @@ -776,7 +776,7 @@ def on_send_order(self, packet: dict) -> None: # 请求本身格式错误(没有委托的回报数据) if packet["code"] != "0": if not data: - order = self.reqid_order_map[packet["id"]] + order: OrderData = self.reqid_order_map[packet["id"]] order.status = Status.REJECTED self.gateway.on_order(order) return @@ -787,8 +787,8 @@ def on_send_order(self, packet: dict) -> None: if code == "0": return - orderid = d["clOrdId"] - order = self.gateway.get_order(orderid) + orderid: str = d["clOrdId"] + order: OrderData = self.gateway.get_order(orderid) if not order: return order.status = Status.REJECTED @@ -838,7 +838,7 @@ def login(self) -> None: def subscribe_topic(self) -> None: """订阅委托、资金和持仓推送""" - okex_req = { + okex_req: dict = { "op": "subscribe", "args": [ { @@ -874,7 +874,7 @@ def send_order(self, req: OrderRequest) -> str: count_str = str(self.order_count).rjust(6, "0") orderid = f"{self.connect_time}{count_str}" - # 生成委托请求 + # 生成委托亲求 args: dict = { "instId": req.symbol, "clOrdId": orderid, @@ -941,7 +941,7 @@ def parse_timestamp(timestamp: str) -> datetime: def get_float_value(data: dict, key: str) -> float: """获取字典中对应键的浮点数值""" - data_str = data.get(key, "") + data_str: str = data.get(key, "") if not data_str: return 0.0 return float(data_str) From ab043d57c0d77bca3f93031d083a75e5d0f7c7eb Mon Sep 17 00:00:00 2001 From: noranhe <63988546+noranhe@users.noreply.github.com> Date: Sat, 8 May 2021 22:41:00 +0800 Subject: [PATCH 2/2] Update okex_gateway.py --- vnpy_okex/okex_gateway.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vnpy_okex/okex_gateway.py b/vnpy_okex/okex_gateway.py index a31b852..c9c5719 100644 --- a/vnpy_okex/okex_gateway.py +++ b/vnpy_okex/okex_gateway.py @@ -874,7 +874,7 @@ def send_order(self, req: OrderRequest) -> str: count_str = str(self.order_count).rjust(6, "0") orderid = f"{self.connect_time}{count_str}" - # 生成委托亲求 + # 生成委托请求 args: dict = { "instId": req.symbol, "clOrdId": orderid,