From 0fd1901ada2c8ab78f990f6b887dfbcbcec50019 Mon Sep 17 00:00:00 2001 From: nanoric Date: Fri, 15 Mar 2019 04:28:23 -0400 Subject: [PATCH] =?UTF-8?q?[Add]=20OesGateway:=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E4=B8=80=E4=BA=9B=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vnpy/gateway/oes/oes_gateway.py | 9 ++++++++- vnpy/gateway/oes/oes_td.py | 13 ++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/vnpy/gateway/oes/oes_gateway.py b/vnpy/gateway/oes/oes_gateway.py index dbdb922c..dc5cea83 100644 --- a/vnpy/gateway/oes/oes_gateway.py +++ b/vnpy/gateway/oes/oes_gateway.py @@ -17,7 +17,14 @@ from .utils import config_template class OesGateway(BaseGateway): """ - VN Trader Gateway for BitMEX connection. + VN Trader Gateway for OES + + Because the design of OES API, multiple gateway instance with a same account is currently + not supported. + running multiple gateway instance with the same account will make send_order and + cancel_order fail frequently, because: + * seq_index is not unique between instances + * value range of client_id is too small to create a unique hash for different client. """ default_setting = { diff --git a/vnpy/gateway/oes/oes_td.py b/vnpy/gateway/oes/oes_td.py index 3878dbaf..a2240a2a 100644 --- a/vnpy/gateway/oes/oes_td.py +++ b/vnpy/gateway/oes/oes_td.py @@ -202,10 +202,9 @@ class OesTdMessageLoop: try: i = self._td.get_order(data.clSeqNo) except KeyError: - # todo: maybe I should find a way to disable subscription of orders at startup - return - vt_order = i.vt_order + return # rejected order created by others, don't need to care. + vt_order = i.vt_order if vt_order == Status.ALLTRADED: return @@ -222,8 +221,10 @@ class OesTdMessageLoop: data = d.rptMsg.rptBody.ordInsertRsp if not data.origClSeqNo: + # normal order i = self._td.get_order(data.clSeqNo) else: + # data.ordStatus == eOesOrdStatusT.OES_ORD_STATUS_CANCEL_DONE: i = self._td.get_order(data.origClSeqNo) vt_order = i.vt_order vt_order.status = STATUS_OES2VT[data.ordStatus] @@ -238,8 +239,10 @@ class OesTdMessageLoop: data: OesOrdCnfmT = d.rptMsg.rptBody.ordCnfm if not data.origClSeqNo: + # normal order i = self._td.get_order(data.clSeqNo) else: + # data.ordStatus == eOesOrdStatusT.OES_ORD_STATUS_CANCEL_DONE: i = self._td.get_order(data.origClSeqNo) vt_order = i.vt_order @@ -691,7 +694,7 @@ class OesTdApi: i = self.get_order(data.clSeqNo) vt_order = i.vt_order vt_order.status = STATUS_OES2VT[data.ordStatus] - vt_order.volume = data.ordQty - data.canceledQty + vt_order.volume = data.ordQty vt_order.traded = data.cumQty self.gateway.on_order(copy(vt_order)) return 1 @@ -717,7 +720,7 @@ class OesTdApi: i = self.get_order(data.clSeqNo) vt_order = i.vt_order vt_order.status = STATUS_OES2VT[data.ordStatus] - vt_order.volume = data.ordQty - data.canceledQty + vt_order.volume = data.ordQty vt_order.traded = data.cumQty self.gateway.on_order(copy(vt_order)) except KeyError: