[Mod]修改CTA策略引擎的委托函数,添加自动转换委托功能
This commit is contained in:
parent
276c0e02fb
commit
92c446c5b7
@ -91,6 +91,7 @@ class CtaEngine(object):
|
||||
req = VtOrderReq()
|
||||
req.symbol = contract.symbol
|
||||
req.exchange = contract.exchange
|
||||
req.vtSymbol = contract.vtSymbol
|
||||
req.price = self.roundToPriceTick(contract.priceTick, price)
|
||||
req.volume = volume
|
||||
|
||||
@ -117,13 +118,22 @@ class CtaEngine(object):
|
||||
req.direction = DIRECTION_LONG
|
||||
req.offset = OFFSET_CLOSE
|
||||
|
||||
vtOrderID = self.mainEngine.sendOrder(req, contract.gatewayName) # 发单
|
||||
# 委托转换
|
||||
reqList = self.mainEngine.convertOrderReq(req)
|
||||
orderIDList = []
|
||||
|
||||
if not reqList:
|
||||
return orderIDList
|
||||
|
||||
for convertedReq in reqList:
|
||||
vtOrderID = self.mainEngine.sendOrder(convertedReq, contract.gatewayName) # 发单
|
||||
self.orderStrategyDict[vtOrderID] = strategy # 保存vtOrderID和策略的映射关系
|
||||
orderIDList.append(vtOrderID)
|
||||
|
||||
self.writeCtaLog(u'策略%s发送委托,%s,%s,%s@%s'
|
||||
%(strategy.name, vtSymbol, req.direction, volume, price))
|
||||
|
||||
return vtOrderID
|
||||
return orderIDList
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def cancelOrder(self, vtOrderID):
|
||||
|
Loading…
Reference in New Issue
Block a user