¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 Groups.io

why bracket quantity reduces after parent filled?


 

hello community,
I am facing a problem with generating bracket orders.
lets say i'm generating a bracket order with parent,take-profit,and stoploss.
i'm sending the order with different quantity for the stoploss and takeprofit.
for example:
the quantity of the parent is 1,
the quantity of the profit is 3,
the quantity of the stoploss is 4.
?
the order is being transmitted into the TWS with transmit = false , and everything is?
good.
?
?
but the problem comes when i hit transmit to the parent, automatically the quantity of both
take profit and stoploss is changing to the quantity of the parent.
why it changes and not remain the same quantity ?
you can see that it was 3 and 4 - and after pressing transmit it changes to 0 , 1 , and 1??
?
?
pic1:
?
pic2 (after submitting):
?
?
?
?
?


 

That is how bracket orders are supposed to work. You can search our archive since we had lots of discussions about this before. One that comes to mind from a couple weeks ago can be found here.

When a bracket order is transmitted to IBKR, IBKR adjusts the requested quantities for all attached orders (profit, loss, others) to the quantity of the parent. And once the parent order starts actually filing, IBKR again adjusts all attached orders to the actual fill quantity of the parent order.

If you want a different behavior, you need to model your strategy with other order types or combinations of? hedge orders, pairs orders, OCA groups, order conditioning or other constructs.

´³¨¹°ù²µ±ð²Ô


On Thu, Sep 7, 2023 at 09:30 AM, <ofirbux@...> wrote:
hello community,
I am facing a problem with generating bracket orders.
lets say i'm generating a bracket order with parent,take-profit,and stoploss.
i'm sending the order with different quantity for the stoploss and takeprofit.
for example:
the quantity of the parent is 1,
the quantity of the profit is 3,
the quantity of the stoploss is 4.
?
the order is being transmitted into the TWS with transmit = false , and everything is?
good.
?
?
but the problem comes when i hit transmit to the parent, automatically the quantity of both
take profit and stoploss is changing to the quantity of the parent.
why it changes and not remain the same quantity ?
you can see that it was 3 and 4 - and after pressing transmit it changes to 0 , 1 , and 1??
?


 

¿ªÔÆÌåÓý

Hello,

If you think about it, it's not that weird. From your example, you plan to take profit and also immediately go short at the same level (sell 3 on position of 1, ends up -2). Also, that short order would not have a protected stop. It's probably better to enter a separate order (with bracket) that opens a short postition.

The use of brackets is great though, or make it an oca order, even better with trail and what more. ;-)

Take care,
Raoul



On 07-09-2023 16:30, ofirbux@... wrote:

hello community,
I am facing a problem with generating bracket orders.
lets say i'm generating a bracket order with parent,take-profit,and stoploss.
i'm sending the order with different quantity for the stoploss and takeprofit.
for example:
the quantity of the parent is 1,
the quantity of the profit is 3,
the quantity of the stoploss is 4.
?
the order is being transmitted into the TWS with transmit = false , and everything is?
good.
?
?
but the problem comes when i hit transmit to the parent, automatically the quantity of both
take profit and stoploss is changing to the quantity of the parent.
why it changes and not remain the same quantity ?
you can see that it was 3 and 4 - and after pressing transmit it changes to 0 , 1 , and 1??
?
?
pic1:
?
pic2 (after submitting):
?
?
?
?
?


 

what if i want to go from position 1 , to position -1 of the equity?
lets say im in position 0 , I put an order with quantity 1,tp 1, sl 1, and filled it, now im in position 1.
what if i want to go to position -1? i should put quantity -2, tp and sl still 1.
but as soon as i transmit - the tp and sl are going 2 also.
why is that ? (:


 

Then you can't use bracket orders. You read my reply, right?


On Thu, Sep 7, 2023 at 10:22 PM, <ofirbux@...> wrote:
what if i want to go from position 1 , to position -1 of the equity?
lets say im in position 0 , I put an order with quantity 1,tp 1, sl 1, and filled it, now im in position 1.
what if i want to go to position -1? i should put quantity -2, tp and sl still 1.
but as soon as i transmit - the tp and sl are going 2 also.
why is that ? (:


 

Yes , i read it.
I understood that I cannot use bracket - so I'm looking for a solution of what i CAN use.
what is the best approach to go from position 1 to -1 and vice-versa , with different quantities between parent and childs?


 

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 actual entry order fill quantity is known
  • Quantities for all child orders are updated automatically
  • The child orders are now unrelated other than that they share the same group. IBKR automatically wraps the child orders of the bracket into an OCA so that only one child order executes and the others get cancelled.
  • Your client can now change the order quantity for the stop loss order without impacting the other orders in the group. In case the entry order filled completely, you'd simply double the stop loss order quantity. Upon partial fills you'd adjust based on the target reverse position.

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:

  • You place the same bracket order the first path uses
  • You attach a position reversal order to the stop loss order. It has the same same quantity and action (Buy or Sell) as the stop loss order.
  • Should the stop loss order trigger, it closes the position but also activates the attached reversal order.

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):

  • The main bracket has an entry parent order, a profit taker, a stop loss, and a close position at end of day order.
  • The stop loss order is the parent for a position reversal market order. Other order types would work, too.

Hope this helps,

´³¨¹°ù²µ±ð²Ô





On Thu, Sep 7, 2023 at 11:09 PM, <ofirbux@...> wrote:
Yes , i read it.
I understood that I cannot use bracket - so I'm looking for a solution of what i CAN use.
what is the best approach to go from position 1 to -1 and vice-versa , with different quantities between parent and childs?


 

My apologies for the repeat messages, but the original message got inadvertently deleted and the (unmodified) resend had an image upload error that caused it to be sent it with out it.

So here the order example.

´³¨¹°ù²µ±ð²Ô