From e63542c44a42e3963d4657dbd5c5b0982fddd3d6 Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Sat, 30 Mar 2019 23:42:19 +0800 Subject: [PATCH] [Mod]change ctp gateway orderid format to avoid conflict with negative sessionid --- vnpy/gateway/ctp/ctp_gateway.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/vnpy/gateway/ctp/ctp_gateway.py b/vnpy/gateway/ctp/ctp_gateway.py index 68b3baae..fe2784a7 100644 --- a/vnpy/gateway/ctp/ctp_gateway.py +++ b/vnpy/gateway/ctp/ctp_gateway.py @@ -433,7 +433,7 @@ class CtpTdApi(TdApi): def onRspOrderInsert(self, data: dict, error: dict, reqid: int, last: bool): """""" order_ref = data["OrderRef"] - orderid = f"{self.frontid}-{self.sessionid}-{order_ref}" + orderid = f"{self.frontid}_{self.sessionid}_{order_ref}" symbol = data["InstrumentID"] exchange = symbol_exchange_map[symbol] @@ -586,7 +586,7 @@ class CtpTdApi(TdApi): frontid = data["FrontID"] sessionid = data["SessionID"] order_ref = data["OrderRef"] - orderid = f"{frontid}-{sessionid}-{order_ref}" + orderid = f"{frontid}_{sessionid}_{order_ref}" order = OrderData( symbol=symbol, @@ -722,7 +722,7 @@ class CtpTdApi(TdApi): self.reqid += 1 self.reqOrderInsert(ctp_req, self.reqid) - orderid = f"{self.frontid}-{self.sessionid}-{self.order_ref}" + orderid = f"{self.frontid}_{self.sessionid}_{self.order_ref}" order = req.create_order_data(orderid, self.gateway_name) self.gateway.on_order(order) @@ -732,7 +732,7 @@ class CtpTdApi(TdApi): """ Cancel existing order. """ - frontid, sessionid, order_ref = req.orderid.split("-") + frontid, sessionid, order_ref = req.orderid.split("_") ctp_req = { "InstrumentID": req.symbol,