Skip to content

Commit

Permalink
fix gateway debug
Browse files Browse the repository at this point in the history
  • Loading branch information
51bitquant committed Jul 21, 2022
1 parent 1c28f31 commit b5aad5e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 18 deletions.
10 changes: 3 additions & 7 deletions howtrader/gateway/binance/binance_inverse_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ def on_start_user_stream_error(self, exception_type: type, exception_value: Exce
def keep_user_stream(self) -> None:
"""extend listenKey expire time"""
self.keep_alive_count += 1
if self.keep_alive_count < 1200:
if self.keep_alive_count < 600:
return None
self.keep_alive_count = 0

Expand Down Expand Up @@ -679,8 +679,6 @@ def on_query_position(self, data: list, request: Request) -> None:

self.gateway.on_position(position)

self.gateway.write_log("query position successfully")

def on_query_order(self, data: dict, request: Request) -> None:
key = (data["type"], data["timeInForce"])
order_type = ORDERTYPE_BINANCES2VT.get(key, OrderType.LIMIT)
Expand All @@ -701,8 +699,6 @@ def on_query_order(self, data: dict, request: Request) -> None:
)
self.gateway.on_order(order)

self.gateway.write_log("query order successfully")

def on_query_orders(self, data: list, request: Request) -> None:
"""query open orders callback"""
for d in data:
Expand Down Expand Up @@ -874,7 +870,7 @@ def on_keep_user_stream(self, data: dict, request: Request) -> None:
def on_keep_user_stream_failed(self, status_code: str, request: Request):
self.failed_with_timestamp(request)
self.keep_alive_failed_count += 1
if self.keep_alive_failed_count <= 5:
if self.keep_alive_failed_count <= 3:
self.keep_alive_count = 1200000
self.keep_user_stream()
else:
Expand All @@ -887,7 +883,7 @@ def on_keep_user_stream_error(
"""put the listen key failed"""

self.keep_alive_failed_count += 1
if self.keep_alive_failed_count < 5:
if self.keep_alive_failed_count <= 3:
self.keep_alive_count = 1200000
self.keep_user_stream()
else:
Expand Down
7 changes: 3 additions & 4 deletions howtrader/gateway/binance/binance_spot_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ def start_user_stream(self) -> None:
def keep_user_stream(self) -> None:
"""extend listenKey expire time """
self.keep_alive_count += 1
if self.keep_alive_count < 1200:
if self.keep_alive_count < 600:
return None
self.keep_alive_count = 0

Expand Down Expand Up @@ -563,7 +563,6 @@ def on_query_order(self, data: dict, request: Request) -> None:
gateway_name=self.gateway_name,
)
self.gateway.on_order(order)
self.gateway.write_log("query order successfully")

def on_query_orders(self, data: list, request: Request) -> None:
"""query open orders callback"""
Expand Down Expand Up @@ -725,7 +724,7 @@ def on_keep_user_stream(self, data: dict, request: Request) -> None:
def on_keep_user_stream_failed(self, status_code: str, request: Request):
self.failed_with_timestamp(request)
self.keep_alive_failed_count += 1
if self.keep_alive_failed_count <= 5:
if self.keep_alive_failed_count <= 3:
self.keep_alive_count = 1200000
self.keep_user_stream()
else:
Expand All @@ -738,7 +737,7 @@ def on_keep_user_stream_error(
"""put the listen key failed"""

self.keep_alive_failed_count += 1
if self.keep_alive_failed_count <= 5:
if self.keep_alive_failed_count <= 3:
self.keep_alive_count = 1200000
self.keep_user_stream()
else:
Expand Down
10 changes: 3 additions & 7 deletions howtrader/gateway/binance/binance_usdt_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ def start_user_stream(self) -> None:
def keep_user_stream(self) -> None:
"""extend listenKey expire time"""
self.keep_alive_count += 1
if self.keep_alive_count < 1200:
if self.keep_alive_count < 600:
return None
self.keep_alive_count = 0

Expand Down Expand Up @@ -678,8 +678,6 @@ def on_query_position(self, data: list, request: Request) -> None:

self.gateway.on_position(position)

self.gateway.write_log("query position successfully")

def on_query_order(self, data:dict, request: Request) -> None:

key = (data["type"], data["timeInForce"])
Expand All @@ -701,8 +699,6 @@ def on_query_order(self, data:dict, request: Request) -> None:
)
self.gateway.on_order(order)

self.gateway.write_log("query order successfully")

def on_query_orders(self, data: list, request: Request) -> None:
"""query open orders callback"""
for d in data:
Expand Down Expand Up @@ -886,7 +882,7 @@ def on_keep_user_stream(self, data: dict, request: Request) -> None:
def on_keep_user_stream_failed(self, status_code: str, request: Request):
self.failed_with_timestamp(request)
self.keep_alive_failed_count += 1
if self.keep_alive_failed_count <= 5:
if self.keep_alive_failed_count <= 3:
self.keep_alive_count = 1200000
self.keep_user_stream()
else:
Expand All @@ -898,7 +894,7 @@ def on_keep_user_stream_error(
) -> None:
"""put the listen key failed"""
self.keep_alive_failed_count += 1
if self.keep_alive_failed_count <= 5:
if self.keep_alive_failed_count <= 3:
self.keep_alive_count = 1200000
self.keep_user_stream()
else:
Expand Down

0 comments on commit b5aad5e

Please sign in to comment.