Check Status of Order

raptron
raptron edited December 2021 in Python client
kite = KiteConnect(#Enter API Key Here)
webs = KiteTicker(#Enter API Key and Access Token)
def on_order_update(ws, data):
logging.info(f"{data['status']}.")
webs.on_order_update = on_order_update

To check the status of an order, can we do:

kite.place_order(#Insert Logic)
if webs.on_order_update == 'COMPLETE':
#Further Logic

Or is there any other method that might be more preferable?
  • SRIJAN
    Just do it as in the documentation. order_id=kite.place_order(order_params). To check order_status,you can do kite.order_history(order_id).
  • raptron
    I just want to check if the order has been complete, not necessarily the order I.D.
  • SRIJAN
    Order_history function gives all the details of the particular order. You can extract the status value from it.
  • raptron
    Thanks boss. @rakeshr you can close this thread.
  • raptron
    Does the 'data' key in order history always have exactly 3 dictionaries or can it have more?
  • SRIJAN
    SRIJAN edited December 2021
    No,it can be less or more.
  • raptron
    @rakeshr, @sujith any answers whatsoever?
  • rakeshr
    To check the status of an order, can we do:
    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.
  • raptron
    @rakeshr would the method I described above work?
  • rakeshr
    Do you mean websocket on_order_update? This one?
    def on_order_update(ws, data):
    logging.info(f"{data['status']}.")
    webs.on_order_update = on_order_update
  • SRIJAN
    @raptron No. It should be like

    if data['status']=='COMPLETE':
    pass
  • raptron
    @rakeshr yes on that one
  • raptron
    @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?
  • rakeshr
    You can use on_order_update as well inside while loop, just make sure you are assigning proper callback for the same.
  • raptron
    raptron edited December 2021
    But how do I define inside the while loop? Anybody any suggestions?
Sign In or Register to comment.