How to handle "400 - Order request timed out" KiteException when placing a Cover Order

While placing a cover order I got "400 - Order request timed out" KiteException. The program assumed that the order request had failed and retried multiple times in quick succession. Each time getting the same exception.
In reality 3 of the 5 attempts tried went through and the orders were placed. I suspect that the other two calls were rejected because the margin must have been exhausted.
This is a big problem because first, multiple unwanted orders got placed. Second my system wasn't even aware that the orders had been placed and as a result couldn't manage the stoploss on those orders resulting in those trades yielding unnecessary losses.

How are we supposed to handle this exception? What assumptions should we make if we get this exception? How can we check if the order has actually gone through, since we don't even know the order id?
  • sujith
    You can refer to this similar thread.
  • sudipto
    Thanks got it... I should check the order book after such an exception. If I find a new order then the order went through, else it didn't.
    However how long should I wait and then check the order book to be sure that the order didn't go through? 1 second, 2 seconds or maybe 5 seconds?
  • Vivek
    Vivek edited March 6
    We suggest you to wait atleast 60 seconds. You can fetch orderbook every few seconds but wait atleast for a minute before considering as a bad request. Ideally the order get reflected in orderbook immediately but in some rare scenarios its possible that it might take more time.
  • sudipto
    @Vivek ... Thanks for the clarification... I guess it will be best to move this activity to a separate thread in that case. Will do the needful.
This discussion has been closed.