[Mod]实现SpreadTrading模块的平仓委托自动转换功能
This commit is contained in:
parent
c700141aaa
commit
cc3fdfc569
@ -366,9 +366,16 @@ class StAlgoEngine(object):
|
|||||||
req.price = price + payup * contract.priceTick
|
req.price = price + payup * contract.priceTick
|
||||||
else:
|
else:
|
||||||
req.price = price - payup * contract.priceTick
|
req.price = price - payup * contract.priceTick
|
||||||
|
|
||||||
|
# 委托转换
|
||||||
|
reqList = self.mainEngine.convertOrderReq(req)
|
||||||
|
vtOrderIDList = []
|
||||||
|
|
||||||
vtOrderID = self.mainEngine.sendOrder(req, contract.gatewayName)
|
for req in reqList:
|
||||||
return vtOrderID
|
vtOrderID = self.mainEngine.sendOrder(req, contract.gatewayName)
|
||||||
|
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