From cc3fdfc5692ebccd45dcbca156b1cb1d9e006198 Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Wed, 25 Oct 2017 13:00:01 +0800 Subject: [PATCH] =?UTF-8?q?[Mod]=E5=AE=9E=E7=8E=B0SpreadTrading=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E7=9A=84=E5=B9=B3=E4=BB=93=E5=A7=94=E6=89=98=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E8=BD=AC=E6=8D=A2=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vnpy/trader/app/spreadTrading/stEngine.py | 39 ++++++++--------------- 1 file changed, 13 insertions(+), 26 deletions(-) diff --git a/vnpy/trader/app/spreadTrading/stEngine.py b/vnpy/trader/app/spreadTrading/stEngine.py index f6d63347..5829323f 100644 --- a/vnpy/trader/app/spreadTrading/stEngine.py +++ b/vnpy/trader/app/spreadTrading/stEngine.py @@ -366,9 +366,16 @@ class StAlgoEngine(object): req.price = price + payup * contract.priceTick else: req.price = price - payup * contract.priceTick + + # 委托转换 + reqList = self.mainEngine.convertOrderReq(req) + vtOrderIDList = [] - vtOrderID = self.mainEngine.sendOrder(req, contract.gatewayName) - return vtOrderID + for req in reqList: + vtOrderID = self.mainEngine.sendOrder(req, contract.gatewayName) + vtOrderIDList.append(vtOrderID) + + return vtOrderIDList #---------------------------------------------------------------------- def cancelOrder(self, vtOrderID): @@ -389,45 +396,25 @@ class StAlgoEngine(object): #---------------------------------------------------------------------- def buy(self, vtSymbol, price, volume, payup=0): """买入""" - vtOrderID = self.sendOrder(vtSymbol, DIRECTION_LONG, OFFSET_OPEN, price, volume, payup) - l = [] - - if vtOrderID: - l.append(vtOrderID) - + l = self.sendOrder(vtSymbol, DIRECTION_LONG, OFFSET_OPEN, price, volume, payup) return l #---------------------------------------------------------------------- def sell(self, vtSymbol, price, volume, payup=0): """卖出""" - vtOrderID = self.sendOrder(vtSymbol, DIRECTION_SHORT, OFFSET_CLOSE, price, volume, payup) - l = [] - - if vtOrderID: - l.append(vtOrderID) - + l = self.sendOrder(vtSymbol, DIRECTION_SHORT, OFFSET_CLOSE, price, volume, payup) return l #---------------------------------------------------------------------- def short(self, vtSymbol, price, volume, payup=0): """卖空""" - vtOrderID = self.sendOrder(vtSymbol, DIRECTION_SHORT, OFFSET_OPEN, price, volume, payup) - l = [] - - if vtOrderID: - l.append(vtOrderID) - + l = self.sendOrder(vtSymbol, DIRECTION_SHORT, OFFSET_OPEN, price, volume, payup) return l #---------------------------------------------------------------------- def cover(self, vtSymbol, price, volume, payup=0): """平空""" - vtOrderID = self.sendOrder(vtSymbol, DIRECTION_LONG, OFFSET_CLOSE, price, volume, payup) - l = [] - - if vtOrderID: - l.append(vtOrderID) - + l = self.sendOrder(vtSymbol, DIRECTION_LONG, OFFSET_CLOSE, price, volume, payup) return l #----------------------------------------------------------------------