There are multiple way to fetch order update status. Best would be to use on_order_update, if you are already connected to websocket streaming . If you are not connected to WebSocket, you can use kite.order_history(order_id), if you have order_id of placed order. In some cases, if there is an error time-out/exceptions, then only consider fetching the whole order book using kite.orders().
Does the 'data' key in order history always have exactly 3 dictionaries or can it have more?
Each dictionary in data is actually different order status the requested order_id has gone through. It can be any number depending on your order params. You can refer to different order status orders go through here.
@rakeshr I am defining this order status check in the while loop and on_order_update is defined outside the while loop. So how do I use the on_order_update function inside the while loop?
on_order_update
, if you are already connected to websocket streaming .If you are not connected to WebSocket, you can use
kite.order_history(order_id)
, if you have order_id of placed order.In some cases, if there is an error time-out/exceptions, then only consider fetching the whole order book using kite.orders(). Each dictionary in data is actually different order status the requested order_id has gone through. It can be any number depending on your order params. You can refer to different order status orders go through here.
if data['status']=='COMPLETE':
pass
on_order_update
as well inside while loop, just make sure you are assigning proper callback for the same.