Keyboard Shortcuts
Likes
Search
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,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:
|
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?
toggle quoted message
Show quoted text
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? |
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. |