Exception while placing an order: KiteOrderException

ruchanavjyot1907
ruchanavjyot1907 edited January 2017 in Java client
I got exceptions while placing order today around 19:30 to 20:30 IST, exception is copied below.
Please look into it on high priority in your logs for the root cause. My main order was placed successfully however stoploss order thrown exception, this could have resulted into financial loss.

Exception:

ERROR 2017-01-30 19:39:40,185 [pool-1-thread-1] com.TradeRobotBatch.business.processor.OrderProcessor - Order Exception:
com.TradeRobotBatch.kiteAPI.api.kitehttp.exceptions.KiteOrderException
at com.TradeRobotBatch.kiteAPI.api.kitehttp.KiteRequest.dealWithKiteException(KiteRequest.java:242)
at com.TradeRobotBatch.kiteAPI.api.kitehttp.KiteRequest.postRequest(KiteRequest.java:46)
at com.TradeRobotBatch.kiteAPI.api.kiteconnect.KiteConnect.placeOrder(KiteConnect.java:213)
at com.TradeRobotBatch.business.processor.OrderProcessor.process(OrderProcessor.java:72)
at com.TradeRobotBatch.business.processor.OrderProcessor.process(OrderProcessor.java:1)
at org.springframework.batch.core.step.item.SimpleChunkProcessor.doProcess(SimpleChunkProcessor.java:126)
at org.springframework.batch.core.step.item.SimpleChunkProcessor.transform(SimpleChunkProcessor.java:293)
at org.springframework.batch.core.step.item.SimpleChunkProcessor.process(SimpleChunkProcessor.java:192)
at org.springframework.batch.core.step.item.ChunkOrientedTasklet.execute(ChunkOrientedTasklet.java:75)
at org.springframework.batch.core.step.tasklet.TaskletStep$ChunkTransactionCallback.doInTransaction(TaskletStep.java:406)
at org.springframework.batch.core.step.tasklet.TaskletStep$ChunkTransactionCallback.doInTransaction(TaskletStep.java:330)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133)
at org.springframework.batch.core.step.tasklet.TaskletStep$2.doInChunkContext(TaskletStep.java:271)
at org.springframework.batch.core.scope.context.StepContextRepeatCallback.doInIteration(StepContextRepeatCallback.java:81)
at org.springframework.batch.repeat.support.RepeatTemplate.getNextResult(RepeatTemplate.java:374)
at org.springframework.batch.repeat.support.RepeatTemplate.executeInternal(RepeatTemplate.java:215)
at org.springframework.batch.repeat.support.RepeatTemplate.iterate(RepeatTemplate.java:144)
at org.springframework.batch.core.step.tasklet.TaskletStep.doExecute(TaskletStep.java:257)
at org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:200)
at org.springframework.batch.core.job.SimpleStepHandler.handleStep(SimpleStepHandler.java:148)
at org.springframework.batch.core.job.flow.JobFlowExecutor.executeStep(JobFlowExecutor.java:64)
at org.springframework.batch.core.job.flow.support.state.StepState.handle(StepState.java:67)
at org.springframework.batch.core.job.flow.support.SimpleFlow.resume(SimpleFlow.java:169)
at org.springframework.batch.core.job.flow.support.SimpleFlow.start(SimpleFlow.java:144)
at org.springframework.batch.core.job.flow.FlowJob.doExecute(FlowJob.java:134)
at org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:306)
at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:135)
at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:50)
at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:128)
at com.TradeRobotBatch.business.ScheduledJobRun.runApp(ScheduledJobRun.java:52)
at sun.reflect.GeneratedMethodAccessor39.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:65)
at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.runAndReset(Unknown Source)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(Unknown Source)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
  • sujith
    Hi @ruchanavjyot1907,
    Can you print error message in KiteException ? \
    You can access error message like this kiteException.message
  • ruchanavjyot1907
    ruchanavjyot1907 edited February 2017
    @sujith updated logs are given below, the error message is 'SELL `trigger_price` should be greater than `price`', unable to understand logic behind this error - if my main order is BUY then stoploss order will always be SELL with trigger price lower than actual price. The same way it was working fine till 19th Jan and this error occurred from 30th Jan (I was out of station between 20 to 29th Jan), has anything changed during this period?

    ERROR 2017-01-31 20:02:07,019 [pool-1-thread-1] com.TradeRobotBatch.kiteAPI.api.kitehttp.KiteRequest - OrderResponse Error Type: OrderException
    ERROR 2017-01-31 20:02:07,020 [pool-1-thread-1] com.TradeRobotBatch.kiteAPI.api.kitehttp.KiteRequest - OrderResponse Message: SELL `trigger_price` should be greater than `price`
    ERROR 2017-01-31 20:02:07,020 [pool-1-thread-1] com.TradeRobotBatch.kiteAPI.api.kitehttp.KiteRequest - OrderResponse Error Code: 400
    ERROR 2017-01-31 20:02:07,021 [pool-1-thread-1] com.TradeRobotBatch.business.processor.OrderProcessor - Order Exception:
    com.TradeRobotBatch.kiteAPI.api.kitehttp.exceptions.KiteOrderException
    at com.TradeRobotBatch.kiteAPI.api.kitehttp.KiteRequest.dealWithKiteException(KiteRequest.java:256)
    at com.TradeRobotBatch.kiteAPI.api.kitehttp.KiteRequest.postRequest(KiteRequest.java:51)
    at com.TradeRobotBatch.kiteAPI.api.kiteconnect.KiteConnect.placeOrder(KiteConnect.java:217)
    at com.TradeRobotBatch.business.processor.OrderProcessor.process(OrderProcessor.java:72)
    at com.TradeRobotBatch.business.processor.OrderProcessor.process(OrderProcessor.java:1)
    at org.springframework.batch.core.step.item.SimpleChunkProcessor.doProcess(SimpleChunkProcessor.java:126)
    at org.springframework.batch.core.step.item.SimpleChunkProcessor.transform(SimpleChunkProcessor.java:293)
    at org.springframework.batch.core.step.item.SimpleChunkProcessor.process(SimpleChunkProcessor.java:192)
    at org.springframework.batch.core.step.item.ChunkOrientedTasklet.execute(ChunkOrientedTasklet.java:75)
    at org.springframework.batch.core.step.tasklet.TaskletStep$ChunkTransactionCallback.doInTransaction(TaskletStep.java:406)
    at org.springframework.batch.core.step.tasklet.TaskletStep$ChunkTransactionCallback.doInTransaction(TaskletStep.java:330)
    at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133)
    at org.springframework.batch.core.step.tasklet.TaskletStep$2.doInChunkContext(TaskletStep.java:271)
    at org.springframework.batch.core.scope.context.StepContextRepeatCallback.doInIteration(StepContextRepeatCallback.java:81)
    at org.springframework.batch.repeat.support.RepeatTemplate.getNextResult(RepeatTemplate.java:374)
    at org.springframework.batch.repeat.support.RepeatTemplate.executeInternal(RepeatTemplate.java:215)
    at org.springframework.batch.repeat.support.RepeatTemplate.iterate(RepeatTemplate.java:144)
    at org.springframework.batch.core.step.tasklet.TaskletStep.doExecute(TaskletStep.java:257)
    at org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:200)
    at org.springframework.batch.core.job.SimpleStepHandler.handleStep(SimpleStepHandler.java:148)
    at org.springframework.batch.core.job.flow.JobFlowExecutor.executeStep(JobFlowExecutor.java:64)
    at org.springframework.batch.core.job.flow.support.state.StepState.handle(StepState.java:67)
    at org.springframework.batch.core.job.flow.support.SimpleFlow.resume(SimpleFlow.java:169)
    at org.springframework.batch.core.job.flow.support.SimpleFlow.start(SimpleFlow.java:144)
    at org.springframework.batch.core.job.flow.FlowJob.doExecute(FlowJob.java:134)
    at org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:306)
    at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:135)
    at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:50)
    at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:128)
    at com.TradeRobotBatch.business.ScheduledJobRun.runApp(ScheduledJobRun.java:52)
    at sun.reflect.GeneratedMethodAccessor39.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:65)
    at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    at java.util.concurrent.FutureTask.runAndReset(Unknown Source)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(Unknown Source)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
  • sujith
    @ruchanavjyot1907,
    Can you paste complete request with params here?
  • ruchanavjyot1907
    PFB details (URL and parameters):

    INFO 2017-02-01 16:43:11,487 [pool-1-thread-1] com.TradeRobotBatch.kiteAPI.api.kiteconnect.KiteConnect - Order URL : https://api.kite.trade/orders/regular
    INFO 2017-02-01 16:43:11,488 [pool-1-thread-1] com.TradeRobotBatch.kiteAPI.api.kiteconnect.KiteConnect - ************** Order Parameteres ****************
    INFO 2017-02-01 16:43:11,488 [pool-1-thread-1] com.TradeRobotBatch.kiteAPI.api.kiteconnect.KiteConnect - product : MIS
    INFO 2017-02-01 16:43:11,488 [pool-1-thread-1] com.TradeRobotBatch.kiteAPI.api.kiteconnect.KiteConnect - quantity : 1
    INFO 2017-02-01 16:43:11,488 [pool-1-thread-1] com.TradeRobotBatch.kiteAPI.api.kiteconnect.KiteConnect - trigger_price : 3560
    INFO 2017-02-01 16:43:11,488 [pool-1-thread-1] com.TradeRobotBatch.kiteAPI.api.kiteconnect.KiteConnect - price : 3560
    INFO 2017-02-01 16:43:11,489 [pool-1-thread-1] com.TradeRobotBatch.kiteAPI.api.kiteconnect.KiteConnect - tradingsymbol : CRUDEOILM17FEBFUT
    INFO 2017-02-01 16:43:11,489 [pool-1-thread-1] com.TradeRobotBatch.kiteAPI.api.kiteconnect.KiteConnect - exchange : MCX
    INFO 2017-02-01 16:43:11,489 [pool-1-thread-1] com.TradeRobotBatch.kiteAPI.api.kiteconnect.KiteConnect - validity : DAY
    INFO 2017-02-01 16:43:11,490 [pool-1-thread-1] com.TradeRobotBatch.kiteAPI.api.kiteconnect.KiteConnect - transaction_type : SELL
    INFO 2017-02-01 16:43:11,490 [pool-1-thread-1] com.TradeRobotBatch.kiteAPI.api.kiteconnect.KiteConnect - order_type : SL
    INFO 2017-02-01 16:43:11,490 [pool-1-thread-1] com.TradeRobotBatch.kiteAPI.api.kiteconnect.KiteConnect - ************** ************** ****************
  • sujith
    Hi @ruchanavjyot1907,
    For stoploss orders, price and trigger price can't have same value.
    Please go through this blog post to understand why it can't be same.
  • ruchanavjyot1907
    @sujith , earlier it was working fine with same values (till 19th January), has anything changed from Kite/MCX side during last couple of weeks?
  • sujith
    @ruchanavjyot1907,
    I will check with concerned team and get back to you.
Sign In or Register to comment.