[英]How to set and apply offset to parent order setting in bracket order for Interactive brokers python api?
From TWS, I can place a bracket order where I can place the takeprofit and stoploss order with a setting "apply offset to parent order".在 TWS 中,我可以下一个括号定单,我可以在其中下达止盈和止损定单,并设置“对父定单应用抵消”。 How do one apply same setting "apply offset to parent order" from python API while placing bracket order?
如何在放置括号订单时从python API应用相同的设置“将偏移量应用于父订单”? My code
我的代码
parent.orderId = parentOrderId
parent.action = action
parent.orderType = "STP LMT"
parent.totalQuantity = quantity
parent.auxPrice=auxPrice
parent.lmtPrice = limitPrice #upper price when stop trigerred
#The parent and children orders will need this attribute set to False to prevent accidental executions.
#The LAST CHILD will have it set to True,
parent.transmit = False
takeProfit = Order()
takeProfit.orderId = getNextOrderID()
takeProfit.action = "SELL" if action == "BUY" else "BUY"
takeProfit.orderType = "LMT"
takeProfit.totalQuantity = quantity
takeProfit.lmtPrice = takeProfitLimitPrice
takeProfit.parentId = parentOrderId
takeProfit.transmit = False
stopLoss = Order()
stopLoss.orderId = getNextOrderID()
stopLoss.action = "SELL" if action == "BUY" else "BUY"
stopLoss.orderType = "STP"
#Stop trigger price
stopLoss.auxPrice = stopLossPrice
stopLoss.totalQuantity = quantity
stopLoss.parentId = parentOrderId
#In this case, the low side order will be the last child being sent. Therefore, it needs to set this attribute to True
#to activate all its predecessors
stopLoss.transmit = True
I wrote to IB team.我写信给 IB 团队。 Got this reply
收到了这个回复
Thank you for reaching out to Interactive Brokers.The said settings are related to presets and currently, there are no APIs which can configure the said settings.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.