TWS API bracket order get parent filled price for profit taker

Discussion in 'Automated Trading' started by stewegg, May 28, 2020.

  1. stewegg

    stewegg

    Hi,

    I currently have bracket order that's placing orders with set prices as shown below.
    However, I would like to use the parent order filled price for profit taker and stop loss order.
    I have tried using .orderStatus.avgFillPrice but keep getting "0" as return.
    How can I resolve this?

    Code:
    bracket = ib_val.bracketOrder("BUY", 200, current_price, current_price + 2, current_price - 1)
    bracket.parent.orderType = "MKT"
    for each_order in bracket:
               orderTrade = ib_val.placeOrder(contract_val, each_order)
                orderTrade.orderStatus.status = "Submitted"
    


    Thank you very much.,
     
  2. d08

    d08

    As the parent order hasn't been filled, the price is obviously unknown (that's why orderStatus reports 0). You're better off sending a simple target (calculated using the fill) as it fills.
     
  3. stewegg

    stewegg

    I understand that part.
    Would I be able to replace the take profit and stop loss prices AFTER the parent market order is filled?
    If so, how would I do that?


    Thank you very much.