Couldn't find that `order_id`

durghy_trades
Hello,

I am trying to get the current limit price for my order and while doing so, I receive the following exception:
kiteconnect.exceptions.GeneralException: Couldn't find that `order_id`.

But I checked my logs and to my surprise the order_id is correct, I am attaching the exception I log, I purposefully log the order_id for which I am requesting the order history for:
The exception handling:
try:
self.current_ask = kite.order_history(self.p_id)[-1]['price']
except Exception as e:
logger.exception(f"error in getting current ask for {self.tradingsymbol}({self.p_id}): {e}")
The exception logged:
error in getting current ask for NEOGEN(220113400203799): Couldn't find that `order_id`.

If I try kite.order_history(220113400203799), it works fine. Can you kindly explain the issue?
  • rakeshr
    Didn't get?
    Are you trying to say that, when you initially made the request to fetch kite.order_history(self.p_id), it has thrown error but second request for same order_id went fine?
    If yes, it can possibly happen that the order_id at the time of request was not available in order book.
  • durghy_trades
    durghy_trades edited January 2022
    Hello,

    I mean that the self.p_id was a valid input for the function call, and yet I received an exception: ''Couldn't find that `order_id` ''.

    If the order_id is valid, why do I get an exception? Even if the order is not open and is in validation pending status, the very reason I received an order_id after using kite.place_order should mean that kite.order_history() for the same order_id should not throw an exception ''Couldn't find that `order_id` ''

    Initially, I thought that my input was wrong, i.e, I am storing the order_id incorrectly, but when I logged the exception, I realized that the input was correct and thus am confused about the exception.
  • sujith
    Once you place an order, it goes through a lot of hops before reaching the exchange.
    Each status change represents different state that order has gone through.
    Once you place an order on Kite Connect, it goes to our server and goes through our internal mini RMS and then goes to the OMS vendor which again has a RMS and then OMS and then via a lease line hits the exchange.

    In this process, when Kite trade places an order at OMS, we receive order id in response which is sent back to user. It takes a while for orderbook to be updated because it is a different process. If you receive an order id then I would suggest add a few milliseconds or seconds delay before fetching orderbook or order history.
This discussion has been closed.