Clarification about KiteConnect.CancelOrder() method in the API

sudipto
Hi,
Please refer to the attached image of the javadoc about the method KiteConnect.CancelOrder()... It is mentioned in the description that "Cancel/exit special orders like BO, CO".
By this I understood that MIS Orders of the variety "Regular" cannot be cancelled using this method call.
On the other hand in the parameters of this method according to the documentation you can provide the parameter "regular" to the variety parameter. So now I am confused. Can we exit an MIS buy or sell order of the "regular" variety, especially since it does not have any "ParentOrderId".



  • sujith
    You can refer to the examples here.
  • sudipto
    sudipto edited February 2021
    Thanks. I think I got it. CancelOrder() has two over loaded variants.
    One variant takes 2 parameters - order_id and variety, which is to be used for cancelling "regular" orders. In this variant the variety parameter should always be "regular".
    The second variant takes 3 parameters - order_id, parent_order_id and variety, which is to used for cancelling BO and CO orders. In this variant the variety parameter should only be either "BO" or "CO".

    Is this understanding correct?
  • sujith
    Yes, it is similar to the method overloading concept.
  • sudipto
    @sujith ,
    I just wanted to clarify the following two cases in case of a "Regular" MIS order...
    1. Suppose I have a Regular MIS order with order id 123, which is a buy order on Nifty, quantity 75 and has the status "complete". Then after some time if I call CancelOrder("123", "regular") to exit this position, then Zerodha will create a reverse "regular" order of sell Nifty, quantity 75 and return me the order id of the new order?
    2. Suppose the above order's status is "trigger_pending" due to limit not having being reached, or is "open". The same API call will simply cancel the existing order, and return back the same order id i.e. 123

    Is this understanding correct?
  • sujith
    1. Suppose I have a Regular MIS order with order id 123, which is a buy order on Nifty, quantity 75 and has the status "complete". Then after some time if I call CancelOrder("123", "regular") to exit this position, then Zerodha will create a reverse "regular" order of sell Nifty, quantity 75 and return me the order id of the new order?
    If you cancel again, it will throw an error saying the system couldn't cancel the order. It will not place a new order.
    2. Suppose the above order's status is "trigger_pending" due to limit not having being reached, or is "open". The same API call will simply cancel the existing order, and return back the same order id i.e. 123
    Yes, if an order is not executed then it will only cancel the order.
Sign In or Register to comment.