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?