'Order cannot be cancelled as it is being processed' error while placing exit orders

samba
Line 84237: INFO: {"status":"success","data":{"order_id":"240327200070722"}}
Line 84241: INFO: OrderPlaced :240327200070722
Line 84243: INFO: Order update received for: 240327200070722OrderStatus:OPEN
Line 84245: INFO: Order update received for: 240327200070722OrderStatus:COMPLETE
Line 84249: INFO: --> GET https://api.kite.trade/orders/240327200070722
Line 84259: INFO: <-- 200 OK https://api.kite.trade/orders/240327200070722 (338ms)

Line 90471: INFO: --> DELETE https://api.kite.trade/orders/regular/240327200070722
Line 90717: INFO: <-- 400 Bad Request https://api.kite.trade/orders/regular/240327200070722 (363ms)


Mar 27, 2024 9:29:02 AM okhttp3.internal.platform.Platform log
INFO: {"status":"error","message":"Order cannot be cancelled as it is being processed. Try later.","data":null,"error_type":"InputException"}
Mar 27, 2024 9:29:02 AM okhttp3.internal.platform.Platform log
INFO: <-- END HTTP (135-byte body)
Mar 27, 2024 9:29:02 AM com.samba.MISOrderHandler run
SEVERE: KiteException
com.zerodhatech.kiteconnect.kitehttp.exceptions.InputException
at com.zerodhatech.kiteconnect.kitehttp.KiteResponseHandler.dealWithException(KiteResponseHandler.java:54)
at com.zerodhatech.kiteconnect.kitehttp.KiteResponseHandler.handle(KiteResponseHandler.java:20)
at com.zerodhatech.kiteconnect.kitehttp.KiteRequestHandler.deleteRequest(KiteRequestHandler.java:117)
at com.zerodhatech.kiteconnect.KiteConnect.cancelOrder(KiteConnect.java:338)
at com.samba.MISOrderHandler.exitTargetOrder(MISOrderHandler.java:152)
at com.samba.MISOrderHandler.run(MISOrderHandler.java:68)
at java.lang.Thread.run(Unknown Source)


Not sure why it is failing. Can you please let me know what is wrong for cancel order.


Thanks,
Samba
  • sujith
    One can only cancel a pending order. You need to check if it is already executed.
  • samba
    it is already executed. you can see the order status as 'completed' and the cancel order is after couple 0.5 hrs. since it is not cancelled, auto square off triggered and charged 50rs for that.... for exit orders do we have any other API other than cancel order from kite connect???

    it is still failing..

    Thanks,
    Samba
  • sujith
    Cancel order will only cancel a pending or partially filled order. You need to place a new order with same quantity and product type but opposite transaction type to exit a position.
  • samba
    Ok thank you
This discussion has been closed.