From 81c7e105ab765071923002af1b5098a7c63fe301 Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Wed, 24 Jul 2019 10:46:25 +0800 Subject: [PATCH 1/3] [Fix] no vt_orderid return after sending order --- vnpy/gateway/rpc/rpc_gateway.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vnpy/gateway/rpc/rpc_gateway.py b/vnpy/gateway/rpc/rpc_gateway.py index c9ad39a8..a1807adb 100644 --- a/vnpy/gateway/rpc/rpc_gateway.py +++ b/vnpy/gateway/rpc/rpc_gateway.py @@ -50,7 +50,7 @@ class RpcGateway(BaseGateway): def send_order(self, req: OrderRequest): """""" gateway_name = self.symbol_gateway_map.get(req.vt_symbol, "") - self.client.send_order(req, gateway_name) + return self.client.send_order(req, gateway_name) def cancel_order(self, req: CancelRequest): """""" From 15de4c1e1b3adc7ae3ba0a36f48c0b3fe2f45b5a Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Wed, 24 Jul 2019 12:36:23 +0800 Subject: [PATCH 2/3] [Mod] no throw when RestClient catches exception, only write log message --- vnpy/gateway/hbdm/hbdm_gateway.py | 13 +++++++++++++ vnpy/gateway/huobi/huobi_gateway.py | 15 ++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/vnpy/gateway/hbdm/hbdm_gateway.py b/vnpy/gateway/hbdm/hbdm_gateway.py index 743ae2a0..ea754267 100644 --- a/vnpy/gateway/hbdm/hbdm_gateway.py +++ b/vnpy/gateway/hbdm/hbdm_gateway.py @@ -752,6 +752,19 @@ class HbdmRestApi(RestClient): if not issubclass(exception_type, ConnectionError): self.on_error(exception_type, exception_value, tb, request) + def on_error( + self, exception_type: type, exception_value: Exception, tb, request: Request + ): + """ + Callback to handler request exception. + """ + msg = f"触发异常,状态码:{exception_type},信息:{exception_value}" + self.gateway.write_log(msg) + + sys.stderr.write( + self.exception_detail(exception_type, exception_value, tb, request) + ) + def check_error(self, data: dict, func: str = ""): """""" if data["status"] != "error": diff --git a/vnpy/gateway/huobi/huobi_gateway.py b/vnpy/gateway/huobi/huobi_gateway.py index e57088d5..e66ce614 100644 --- a/vnpy/gateway/huobi/huobi_gateway.py +++ b/vnpy/gateway/huobi/huobi_gateway.py @@ -440,7 +440,20 @@ class HuobiRestApi(RestClient): self.gateway.write_log(f"委托撤单成功:{order.orderid}") self.order_manager.on_order(order) - + + def on_error( + self, exception_type: type, exception_value: Exception, tb, request: Request + ): + """ + Callback to handler request exception. + """ + msg = f"触发异常,状态码:{exception_type},信息:{exception_value}" + self.gateway.write_log(msg) + + sys.stderr.write( + self.exception_detail(exception_type, exception_value, tb, request) + ) + def check_error(self, data: dict, func: str = ""): """""" if data["status"] != "error": From f85a7a54d53fd0296e2b6798317b70f83d54c331 Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Wed, 24 Jul 2019 12:47:24 +0800 Subject: [PATCH 3/3] [Fix] import sys module --- vnpy/gateway/hbdm/hbdm_gateway.py | 1 + vnpy/gateway/huobi/huobi_gateway.py | 1 + 2 files changed, 2 insertions(+) diff --git a/vnpy/gateway/hbdm/hbdm_gateway.py b/vnpy/gateway/hbdm/hbdm_gateway.py index ea754267..5a822659 100644 --- a/vnpy/gateway/hbdm/hbdm_gateway.py +++ b/vnpy/gateway/hbdm/hbdm_gateway.py @@ -9,6 +9,7 @@ import json import zlib import hashlib import hmac +import sys from copy import copy from datetime import datetime from threading import Lock diff --git a/vnpy/gateway/huobi/huobi_gateway.py b/vnpy/gateway/huobi/huobi_gateway.py index e66ce614..08c18e05 100644 --- a/vnpy/gateway/huobi/huobi_gateway.py +++ b/vnpy/gateway/huobi/huobi_gateway.py @@ -9,6 +9,7 @@ import json import zlib import hashlib import hmac +import sys from copy import copy from datetime import datetime