public Order cancelOrder(String orderId, String variety)

rktheinvestor1
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?
  • sujith
    Hi @rktheinvestor1,

    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.
  • rktheinvestor1
    The api has only two parametes, how do i send both?
  • sujith
    what client are you using?
  • rktheinvestor1
    rktheinvestor1 edited November 2016
    @sujith

    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
    You can send BO params in a map. We will have to make some changes to javakiteconnect. We will release it soon.
  • sujith
    When did you get this error? Is this consistent or intermittent?
    Can you mention at what time you tried this?
  • rktheinvestor1
    @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"
  • sujith
    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.
  • rktheinvestor1
    rktheinvestor1 edited November 2016
    @sujith

    How soon?
  • rktheinvestor1
    rktheinvestor1 edited November 2016
    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;
    }
  • sujith
    We will release it in couple of days.
  • sujith
    Hi @rktheinvestor1,

    Checkout new release javakiteconnect v1.4.1. You can exit bracket order.
This discussion has been closed.