From 92c446c5b706bfcf649324ce55878202f463cdc2 Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Wed, 20 Sep 2017 10:59:46 +0800 Subject: [PATCH] =?UTF-8?q?[Mod]=E4=BF=AE=E6=94=B9CTA=E7=AD=96=E7=95=A5?= =?UTF-8?q?=E5=BC=95=E6=93=8E=E7=9A=84=E5=A7=94=E6=89=98=E5=87=BD=E6=95=B0?= =?UTF-8?q?=EF=BC=8C=E6=B7=BB=E5=8A=A0=E8=87=AA=E5=8A=A8=E8=BD=AC=E6=8D=A2?= =?UTF-8?q?=E5=A7=94=E6=89=98=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vnpy/trader/app/ctaStrategy/ctaEngine.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/vnpy/trader/app/ctaStrategy/ctaEngine.py b/vnpy/trader/app/ctaStrategy/ctaEngine.py index 49dd7987..782f189f 100644 --- a/vnpy/trader/app/ctaStrategy/ctaEngine.py +++ b/vnpy/trader/app/ctaStrategy/ctaEngine.py @@ -91,6 +91,7 @@ class CtaEngine(object): req = VtOrderReq() req.symbol = contract.symbol req.exchange = contract.exchange + req.vtSymbol = contract.vtSymbol req.price = self.roundToPriceTick(contract.priceTick, price) req.volume = volume @@ -116,14 +117,23 @@ class CtaEngine(object): elif orderType == CTAORDER_COVER: req.direction = DIRECTION_LONG req.offset = OFFSET_CLOSE + + # 委托转换 + reqList = self.mainEngine.convertOrderReq(req) + orderIDList = [] - vtOrderID = self.mainEngine.sendOrder(req, contract.gatewayName) # 发单 - self.orderStrategyDict[vtOrderID] = strategy # 保存vtOrderID和策略的映射关系 - + if not reqList: + return orderIDList + + for convertedReq in reqList: + vtOrderID = self.mainEngine.sendOrder(convertedReq, contract.gatewayName) # 发单 + self.orderStrategyDict[vtOrderID] = strategy # 保存vtOrderID和策略的映射关系 + orderIDList.append(vtOrderID) + self.writeCtaLog(u'策略%s发送委托,%s,%s,%s@%s' %(strategy.name, vtSymbol, req.direction, volume, price)) - return vtOrderID + return orderIDList #---------------------------------------------------------------------- def cancelOrder(self, vtOrderID):