[Mod]实现SpreadTrading模块的平仓委托自动转换功能
This commit is contained in:
parent
c700141aaa
commit
cc3fdfc569
@ -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
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user