A group of orders for the same instrument with parent/child relationship is ... a bracket order. You probably could build an order construct without parent/child relationships for your scenario (using groups, and other features) but it will be challenging (or impossible) to protect your orders from the many things that can go really wrong (such over fills or order failures). We can't design the exact solution for you, but here a couple paths you could explore. Both start with a traditional bracket order for entry, profit taking, stop loss, and other conditions. IBKR synchronizes order quantities based upon actual parent order fill or the entire set of orders gets cancelled. Nothing bad happens even if your client or TWS/IBGW crash or your network connection with IBKR gets disrupted for an extended period of time. The worst case is that the stop-loss order closes the position instead of reversing the position. The first path to implementing position side reversal requires your client to be around and observe all order status callbacks. Once the parent order is filled
The second path you could explore is a tree of bracket orders. You can have up to 20 open orders for the same instrument at any point in time. For this approach:
I have not tried this, so there may be caveats but I'd expect that the position reversal order quantity is updated automatically to the actual stop loss order quantity. This would effectively reverse the position to the actual fill quantity of the entry order (which may be less than the originally requested quantity). You could extend this approach such that the reversal order has siblings in the second level bracket (profit taker, close position at end of day, others) or you could attach profit and loss orders to the reversal order for a third level. Attached an example of a two-level bracket that IBKR accepted (though it has not executed since markers are closed):
Hope this helps, ´³¨¹°ù²µ±ð²Ô On Thu, Sep 7, 2023 at 11:09 PM, <ofirbux@...> wrote: Yes , i read it. |