How can I exit a CO using the API? Lets say, I have bought CRUDEOILM17JULFUT quantity 5 at 10:00:00. Assume that the order got executed but it hasn't hit the SL yet at 11:00:00. How can I exit the position through the API? Should I place a regular sell order? Or should I modify the CO itself to exit?
The "Modifying orders" section in the documentation doesn't have the answer (or I am missing it somehow).
Suppose I place a sell order to square off the position and the CO hits SL at the same time, what happens?
@ramatius, You need to do the something like this,
Map<String, Object> params = new HashMap<>(); params.put("parent_order_id", <parent_order_id>); Order order = kiteconnect.cancelOrder(params, <order_id>, "co");
When you place special orders like bo and co. Counter orders are already placed, So when you cancel it. System will modify that order to type market. So you don't have to place another order.
You can check out example for special order cancel here https://github.com/rainmattertech/javakiteconnect/blob/master/sample/src/Examples.java
You can search for exit bracket order which is same as exiting cover order.
You need to do the something like this,