Cancelling only pending Bracket Orders but not those with 1st leg executed

soumyadeep
Situation 1:
My parent order_id of the Bracket order is "xxxx". I want to cancel the Bracket order that is pending at the moment. i.e. first leg has not been executed.
Using python client, my question is-
Should I use this format-
kite.order_cancel(order_id='xxxx', variety='bo', parent_order_id='xxxx')
or
kite.order_cancel(order_id='xxxx', variety='bo', parent_order_id=None)

Situation 2:
What if I have a BO (with a parent order_id = 'xxxx') whose 1st leg is executed with a target order and a SL order. I want to exit the position. But I dont know the child order ids of the target and SL orders. Can I exit the position by using only the parent id like this-

kite.order_cancel(order_id='xxxx', variety='bo', parent_order_id='xxxx')
or
do I really need to know the child order id (lets say 'pppp' for the target order id) and use like this-
kite.order_cancel(order_id='pppp', variety='bo', parent_order_id='xxxx')

Situation3:
My parent order_id of the Bracket order is "xxxx". I want to cancel the Bracket order that is pending at the moment. i.e. first leg has not been executed. BUT just before I send the cancel order, the first leg gets executed and I dont want to cancel the BO once it's first leg gets executed. Which of the following code should I use to avoid a BO to exit once it's first leg has been executed:

kite.order_cancel(order_id='xxxx', variety='bo', parent_order_id='xxxx')
or
kite.order_cancel(order_id='xxxx', variety='bo', parent_order_id=None)

Kindly give me the right option in each of the situations. That will be immensely helpful.

Thanks in advance
  • gully
    Just adding to @soumyadeep 's thread few other scenarios

    Situation 4:

    Suppose there is partial execution of bo. I had initially placed 10 lots and now only 2 lots have been executed at the limit price. Currently I have 2 open orders(each having different id(parent id being same),lets call it target1 and stoploss1).Now these stoploss and target are for 2 lots only.Now imagining two different situations

    i.) The limit price strikes again, another 3 lots gets executed.Total 5 lot executed 5 pending.
    Do target1 and stoploss order gets updated with 5 lots? or a new(orderId) target order and stoploss order is created?

    ii) The target price is hit.Do the bracket order take the target? If yes then what happens to the pending orders?Does it get cancelled?
  • Vivek
    @soumyadeep

    case 1 - You can't cancel the pending BO order once the first leg is executed. It can only be exited.
    case 2 - You just need to know the parent order id to exit bracket order. You can exit by calling
    kite.order_cancel(order_id='pppp', variety='bo', parent_order_id='xxxx')
    case 3 - SInce first leg is not executed you can cancel like the normal order.
    kite.order_cancel(order_id='xxxx', variety='bo', parent_order_id=None)
  • soumyadeep
    @vivek case 2- You said that I need to know the parent order id only. But then in the code-
    kite.order_cancel(order_id='pppp', variety='bo', parent_order_id='xxxx')
    you suggest that I put 'pppp' in order_id but I don't know the child order id. In that case what should I write in order_id?
  • Vivek
    @soumyadeep My bad, order_id is by default required for any modification or cancellation.
  • soumyadeep
    OK so in case 2, when I just have the parent order id, I write-
    kite.order_cancel(order_id='None', variety='bo', parent_order_id='xxxx')
    will that work?
  • gully
    @vivek any thoughts on situation 4?
  • Vivek
    @gully I'm not sure about that case. Checking with others regarding this.
    @soumyadeep You can't give invalid order_id, you can find the order id of the pending BO order from orderbook.
Sign In or Register to comment.