[Mod]实现SpreadTrading模块的平仓委托自动转换功能
This commit is contained in:
parent
c700141aaa
commit
cc3fdfc569
@ -367,8 +367,15 @@ class StAlgoEngine(object):
|
|||||||
else:
|
else:
|
||||||
req.price = price - payup * contract.priceTick
|
req.price = price - payup * contract.priceTick
|
||||||
|
|
||||||
|
# 委托转换
|
||||||
|
reqList = self.mainEngine.convertOrderReq(req)
|
||||||
|
vtOrderIDList = []
|
||||||
|
|
||||||
|
for req in reqList:
|
||||||
vtOrderID = self.mainEngine.sendOrder(req, contract.gatewayName)
|
vtOrderID = self.mainEngine.sendOrder(req, contract.gatewayName)
|
||||||
return vtOrderID
|
vtOrderIDList.append(vtOrderID)
|
||||||
|
|
||||||
|
return vtOrderIDList
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def cancelOrder(self, vtOrderID):
|
def cancelOrder(self, vtOrderID):
|
||||||
@ -389,45 +396,25 @@ class StAlgoEngine(object):
|
|||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def buy(self, vtSymbol, price, volume, payup=0):
|
def buy(self, vtSymbol, price, volume, payup=0):
|
||||||
"""买入"""
|
"""买入"""
|
||||||
vtOrderID = self.sendOrder(vtSymbol, DIRECTION_LONG, OFFSET_OPEN, price, volume, payup)
|
l = self.sendOrder(vtSymbol, DIRECTION_LONG, OFFSET_OPEN, price, volume, payup)
|
||||||
l = []
|
|
||||||
|
|
||||||
if vtOrderID:
|
|
||||||
l.append(vtOrderID)
|
|
||||||
|
|
||||||
return l
|
return l
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def sell(self, vtSymbol, price, volume, payup=0):
|
def sell(self, vtSymbol, price, volume, payup=0):
|
||||||
"""卖出"""
|
"""卖出"""
|
||||||
vtOrderID = self.sendOrder(vtSymbol, DIRECTION_SHORT, OFFSET_CLOSE, price, volume, payup)
|
l = self.sendOrder(vtSymbol, DIRECTION_SHORT, OFFSET_CLOSE, price, volume, payup)
|
||||||
l = []
|
|
||||||
|
|
||||||
if vtOrderID:
|
|
||||||
l.append(vtOrderID)
|
|
||||||
|
|
||||||
return l
|
return l
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def short(self, vtSymbol, price, volume, payup=0):
|
def short(self, vtSymbol, price, volume, payup=0):
|
||||||
"""卖空"""
|
"""卖空"""
|
||||||
vtOrderID = self.sendOrder(vtSymbol, DIRECTION_SHORT, OFFSET_OPEN, price, volume, payup)
|
l = self.sendOrder(vtSymbol, DIRECTION_SHORT, OFFSET_OPEN, price, volume, payup)
|
||||||
l = []
|
|
||||||
|
|
||||||
if vtOrderID:
|
|
||||||
l.append(vtOrderID)
|
|
||||||
|
|
||||||
return l
|
return l
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def cover(self, vtSymbol, price, volume, payup=0):
|
def cover(self, vtSymbol, price, volume, payup=0):
|
||||||
"""平空"""
|
"""平空"""
|
||||||
vtOrderID = self.sendOrder(vtSymbol, DIRECTION_LONG, OFFSET_CLOSE, price, volume, payup)
|
l = self.sendOrder(vtSymbol, DIRECTION_LONG, OFFSET_CLOSE, price, volume, payup)
|
||||||
l = []
|
|
||||||
|
|
||||||
if vtOrderID:
|
|
||||||
l.append(vtOrderID)
|
|
||||||
|
|
||||||
return l
|
return l
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user