Recommended way for getting update for a BO placed using "place_order" API when it is "COMPLETE"

guanidene
Hi,

What is the recommended way of ensuring bracket order (BO), placed using the "place_order" method of "kiteconnect" module, is successfully COMPLETED? By COMPLETED, I mean the order and all of its child orders are completed and there is no order pending. [I only place "BUY" orders through BO].

This is what I am currently doing -
3. Place the order using "place_order". Save the "order_id".
4. I check if the order got placed by confirming the order exists in "kite.orders()" using above received "order_id"
5. I periodically query "kite.orders" and ensure that ALL orders whose "order_id" or "parent_order_id" (since BO is multi-legged) matches the "order_id" received in Step1 have status of either "REJECTED", "COMPLETE" or "CANCELLED". If yes, then I consider the order as "closed", else order (or one of its spanned orders) is still pending in the system and I go back to step 3 with a small delay.

This entire activity occurs in a separate thread, not the main thread.

Please let me know if there could be a better way of handling this. Better, meaning cleaner Pythonic, hassle free way of handling this.

Please note, I would like my algorithm to take care of all these scenarios successfully...
1. BO are 2 legged, so multiple orders are created , one for BUY and other for SELL.
2. Sometimes the order is executed in multiple orders with different quantity.
.. so please suggest me accordingly.

I have gone thorugh the Zerodha Kite Connect docs. and came across the Postbacks section. It seems this is the recommended way for keeping track of open orders, but I couldn't find a Python API for that. Please correct me know if I am wrong.

Regards,
Pushpak
Sign In or Register to comment.