How to handle the following exceptions...

sudipto
Hi,
Given below is a stack trace of two exceptions. This happened when my program was trying to modify the stop loss of a cover order. I have done thousands of such modifications with this code, so normally this works fine.
The first exception is a timed out exception, which is understandable and the program does a retry. However when it was retried 2 seconds later, I got the second exception. While the message says "Bad Input", I double checked the detailed log and the input sent was correct and the same format input has worked perfectly thousands of times before and even in other trades after this.
My program then tried a third time 2 seconds later, this time while the initial response was was ok, there was no confirmation of the order. I have a separate thread that keeps querying order history of unconfirmed orders. The confirmation never came.
My question is why did this happen, and what is the best way to handle such exceptions if an order gets stuck in this rut?

Sudipto


08-Oct-2020 15:14:06.727 SEVERE [pool-8-thread-1] com.easyhotelier.kite.server.HlServletLogging.exception Exception while modifying stoploss to 11782.7
Code: 504
Message: request 276fl7y6qVb0eDyyzJ1r9WZvjnA9Aqye timed out
com.zerodhatech.kiteconnect.kitehttp.exceptions.NetworkException
at com.zerodhatech.kiteconnect.kitehttp.KiteResponseHandler.dealWithException(KiteResponseHandler.java:58)
at com.zerodhatech.kiteconnect.kitehttp.KiteResponseHandler.handle(KiteResponseHandler.java:20)
at com.zerodhatech.kiteconnect.kitehttp.KiteRequestHandler.putRequest(KiteRequestHandler.java:101)
at com.zerodhatech.kiteconnect.KiteConnect.modifyOrder(KiteConnect.java:328)
at com.easyhotelier.kite.server.KiteSession.modifyOrder(KiteSession.java:85)
at com.easyhotelier.kite.trade.LiveDispatcher.modifyStoploss(LiveDispatcher.java:63)
at com.easyhotelier.kite.trade.model.StoplossManager.execModSLOrder(StoplossManager.java:49)
at com.easyhotelier.kite.trade.model.trade.TradeSet.trailStop(TradeSet.java:208)
at com.easyhotelier.kite.trade.TickDispatcher.put(TickDispatcher.java:65)
at com.easyhotelier.kite.trade.LiveDispatcher.lambda$0(LiveDispatcher.java:39)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
08-Oct-2020 15:14:08.304 SEVERE [pool-8-thread-1] com.easyhotelier.kite.server.HlServletLogging.exception Exception while modifying stoploss to 11782.9
Code: 500
Message: Modify Order Response : Bad Input
com.zerodhatech.kiteconnect.kitehttp.exceptions.GeneralException
at com.zerodhatech.kiteconnect.kitehttp.KiteResponseHandler.dealWithException(KiteResponseHandler.java:52)
at com.zerodhatech.kiteconnect.kitehttp.KiteResponseHandler.handle(KiteResponseHandler.java:20)
at com.zerodhatech.kiteconnect.kitehttp.KiteRequestHandler.putRequest(KiteRequestHandler.java:101)
at com.zerodhatech.kiteconnect.KiteConnect.modifyOrder(KiteConnect.java:328)
at com.easyhotelier.kite.server.KiteSession.modifyOrder(KiteSession.java:85)
at com.easyhotelier.kite.trade.LiveDispatcher.modifyStoploss(LiveDispatcher.java:63)
at com.easyhotelier.kite.trade.model.StoplossManager.execModSLOrder(StoplossManager.java:49)
at com.easyhotelier.kite.trade.model.trade.TradeSet.trailStop(TradeSet.java:208)
at com.easyhotelier.kite.trade.TickDispatcher.put(TickDispatcher.java:65)
at com.easyhotelier.kite.trade.LiveDispatcher.lambda$0(LiveDispatcher.java:39)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)


  • sujith
    This is a message from the OMS. Can you private message the client id and order id for which this happened?
    We will check and get back to you.
    This could be because you modified order more than 25 times.
  • sudipto
    I have private messaged you the order ID.

    You can rule out the scenario of the order being modified more than 25 times. I counted and the order had been modified only 5 times before that. In any case the exception on maximum modifications come with code 429 and message: "Maximum allowed order modifications exceeded". I have already handled this in my code.

    Whereas this exception came with code 500 and a different message of "bad input".
  • sujith
    This happens when some required field is missing while modifying an order. Can you run javakiteconnect in debug mode and give the request and response logs when this happens?
Sign In or Register to comment.