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". How do one apply same setting "apply offset to parent order" from python API while placing bracket order? 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. 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.