Modifying only the pending_qty of an order

Hi Team,

I have written a code that will place an order-> receive order_id -> Pop the last state of the order_id using order_history - > based on the order state it takes a decision.

The scenario is placing an entry order and checking the pending_qty every sec, if the pending_qty is not 0 after a couple of seconds, I need to modify this order to Market/change the trigger price to the LTP.

Using order_id I could change the order_type/trigger price. But what if in the meantime (the time between I decided to modify to the time I place a modified order to Zerodha) the pending_qty is completely filled due to price fluctuation?

1. How could we handle such a scenario?
2. Also while modifying do I need to change the qty to pending_qty?

Looking forward to your answers.
  • sujith
    If order is already executed, you will receive a 400 Input exception when you make a modification request.

    You will have to send quantity field only while modifying the order's quantity. You can know more here.
  • Harry
    Hi Suijth, thank you for the response.

    But how to logically plan to catch this exception? if there is an order state like REJECTED with a reject reason it would be great.

    Where to know about the list of exceptions that an API will throw in a python client?
  • sujith
    You can check out all the exceptions thrown by Kite Connect here.
  • sujith
    The question of creating a state in the Order history doesn't even occur since the request is rejected at the Kite Trade level only and you will see 400 response from Kite Connect instead of 200
  • Harry
    @sujith makes sense. Thank you.
This discussion has been closed.