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 #----------------------------------------------------------------------