Skip to content

Commit

Permalink
Merge pull request #6 from noranhe/main
Browse files Browse the repository at this point in the history
update
  • Loading branch information
vnpy authored May 9, 2021
2 parents f655b2d + ab043d5 commit e707b47
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions vnpy_okex/okex_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,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)
Expand Down Expand Up @@ -777,7 +777,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
Expand All @@ -788,8 +788,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
Expand Down Expand Up @@ -839,7 +839,7 @@ def login(self) -> None:

def subscribe_topic(self) -> None:
"""订阅委托、资金和持仓推送"""
okex_req = {
okex_req: dict = {
"op": "subscribe",
"args": [
{
Expand Down Expand Up @@ -942,7 +942,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)
Expand Down

0 comments on commit e707b47

Please sign in to comment.