To cancel/Exit already executed BO what values do we need to pass orderId - will it be parent order id or BO order id? variety - will it be bo or LIMIT?
Also i am getting below exception when i am executing cancelOrder call.
Order is getting cancelled but seeing this in my application logs. Can you let me know why it is happening? My parameter type is string only.
org.json.JSONException: JSONObject["order_id"] not a string. at org.json.JSONObject.getString(JSONObject.java:721) at com.rainmatter.models.Order.parseOrderPlacedResponse(Order.java:79) at com.rainmatter.kiteconnect.KiteConnect.cancelOrder(KiteConnect.java:272)
@sujith 1. So you mean as of now i cannot exit executed BO using java client? 2. I get the error mentioned earlier always when i try to cancel a BO which is in OPEN state.
Last error was at around Fri Nov 25 12:13:02 IST 2016 when i tried to cancel "tradingSymbol :: MARICO16DECFUT orderId :: 161125000217284 status :: OPEN"
1. Yes for now, you cannot pass extra params so you cannot exit bracket order on javakiteconnect.
2. We will update KiteConnect class with a feature to exit bracket order and then you can check and let me know.
Looks like small issue with the method signature only......if we simply pass "Map params," and comment "Map params = new HashMap();" should be fine i beleive.
/** * Cancels an order. * @param orderId order id of the order to be cancelled. * @param variety [variety="regular"]. Order variety can be bo, co, amo, regular. * @return Order object contains only orderId */ public Order cancelOrder(String orderId, String variety) throws KiteException, JSONException { String url = routes.get("orders.cancel").replace(":variety", variety).replace(":order_id", orderId); Map params = new HashMap();
JSONObject jsonObject = new KiteRequest().deleteRequest(url, authorize(params)); Order order = new Order(); order.parseOrderPlacedResponse(jsonObject); return order; }
You should send both order_id and parent_order_id.
Variety is bo.
Kite supports four order varieties,
1. regular
2. bo
3. co
4. amo
LIMIT is order type not variety.
Also i am getting below exception when i am executing cancelOrder call.
Order is getting cancelled but seeing this in my application logs. Can you let me know why it is happening? My parameter type is string only.
org.json.JSONException: JSONObject["order_id"] not a string.
at org.json.JSONObject.getString(JSONObject.java:721)
at com.rainmatter.models.Order.parseOrderPlacedResponse(Order.java:79)
at com.rainmatter.kiteconnect.KiteConnect.cancelOrder(KiteConnect.java:272)
Can you mention at what time you tried this?
1. So you mean as of now i cannot exit executed BO using java client?
2. I get the error mentioned earlier always when i try to cancel a BO which is in OPEN state.
Last error was at around Fri Nov 25 12:13:02 IST 2016 when i tried to cancel "tradingSymbol :: MARICO16DECFUT orderId :: 161125000217284 status :: OPEN"
2. We will update KiteConnect class with a feature to exit bracket order and then you can check and let me know.
How soon?
/**
* Cancels an order.
* @param orderId order id of the order to be cancelled.
* @param variety [variety="regular"]. Order variety can be bo, co, amo, regular.
* @return Order object contains only orderId
*/
public Order cancelOrder(String orderId, String variety) throws KiteException, JSONException {
String url = routes.get("orders.cancel").replace(":variety", variety).replace(":order_id", orderId);
Map params = new HashMap();
JSONObject jsonObject = new KiteRequest().deleteRequest(url, authorize(params));
Order order = new Order();
order.parseOrderPlacedResponse(jsonObject);
return order;
}
Checkout new release javakiteconnect v1.4.1. You can exit bracket order.