@sujith, today when I canceled a partially executed BO order my entire BO position of particular stock got exited. What are the details you guys need to correct my mistake?
@sujith, in continuation of the issue that I mentioned in the beginning I am facing the same problem still. Below are the steps I followed to cancel the order
1) fetch order_book 2) filter the order_book by order_id that I got while placing the order 3) then check whether the status of order is 'OPEN' 4) if yes then kite.cancel_order(order_id=order_id,variety='bo')
what happened was partially filled order's position got cancelled
In that case, you need to exit second leg orders also with the cancellation request. You need to loop through orderbook to find all the pending orders with parent_order_id same as the first leg order id and then exit them. You can exit one of the second leg order, no need to do it for both. But make sure to handle scenario wherein there can be multiple pairs of second leg orders.
@sujith, I think I am not clear. what I did today was I placed BUY bracket order for 6 shares of JUSTDIAL, but only 2 shares were bought, then I cancelled the partially filled first leg order using kite.cancel_order(order_id=order_id,variety='bo') method, along with the first leg order, second leg orders also got cancelled i.e my buy position(qty 2) of JUSTDIAL got exited automatically - got sold at market price.
@sujith, hope U understood the issue, I canceled the partially filled 2/6 order using kite.cancel_order(order_id=order_id,variety='bo'), along with the original order my position also got closed.
BO - orderid, variety = 'bo',
mis order - orderid, variety = 'regular'
1) fetch order_book
2) filter the order_book by order_id that I got while placing the order
3) then check whether the status of order is 'OPEN'
4) if yes then
kite.cancel_order(order_id=order_id,variety='bo')
what happened was partially filled order's position got cancelled
You need to loop through orderbook to find all the pending orders with parent_order_id same as the first leg order id and then exit them.
You can exit one of the second leg order, no need to do it for both. But make sure to handle scenario wherein there can be multiple pairs of second leg orders.
along with the first leg order, second leg orders also got cancelled i.e my buy position(qty 2) of JUSTDIAL got exited automatically - got sold at market price.