I am getting the following error : kiteconnect.exceptions.NetworkException: request VHCxnyPX61oLTA678SWVJF9nIHSyZsQ7 timed out
However, when i manually pass 'regular' as the variety param and do kite.cancel_order(variety='regular',order_id=order_id) , the pending amo order is successfully cancelled.
Seems to be a bug? Either the variety of AMO orders must change to 'regular' once market opens, or cancel_order must take 'amo' as variety when cancelling pending amo orders
The amo's variety changes once OMS places the order at the exchange after market opens. You will have to send variety as 'regular', if after market order is placed at the exchange after market opens.
But when i pull list of pending orders using kite.orders() during market hours, the variety change is not being reflected. The variety of amo orders is still shown as amo even after OMS places the order at exchange.
I want to run a code that can cancel orders both during market hours and after market hours. Best way is to take the variety of order from kite.orders() and plug it in cancel_order but if the change of variety is not reflected once OMS places order, then it is not possible for me to parse the correct current variety of order.
But when i pull list of pending orders using kite.orders() during market hours, the variety change is not being reflected
The variety field can't be modified once the user places the order. So, variety remains the same in the order book through. But, as @sujith mentioned above, once the order is placed on the exchange all normal order becomes of regular variety. So, you need to keep a regular variety for all such order modifications and cancellations.
I want to run a code that can cancel orders both during market hours and after market hours. Best way is to take the variety of order from kite.orders() and plug it in cancel_order but if the change of variety is not reflected once OMS places order, then it is not possible for me to parse the correct current variety of order.
regular
variety. So, you need to keep a regular variety for all such order modifications and cancellations.