Exiting Cover Orders

"KiteConnect client = new KiteConnect(api_key)
client.cancelOrder(order_id, Constants.VARIETY_CO);

Is this the correct way to exit a cover order with "order_id" being the one for the desired CO to be exited?
  • sujith
    It is same as exiting bracket order. You can check out example here.
  • hardikdesai
    @sujith : How do i put a stop loss and target in cover order? What is the trigger price shown in the example? orderParams.triggerPrice = 30.5;
  • sujith
    Once you place a cover order, the system will take care of placing second leg order. The trigger price value is for the second leg order.
    You can read more about cover order here.
    To understand the exact flow, I would suggest using Kite web or mobile to place a test cover order.
  • hardikdesai
    In CO, how should i place Stop Loss? Is it the same way as in BO i.e in points?
  • sujith
    You need to send trigger price value. You can get trigger price range. Check out example here.
  • hardikdesai
    @sujith : I get a KiteException "Kite Exception while getting Trigger Range: Missing api_key"
    for the below line. I have logged my API Key for the kiteConnect object and it shows correct key. Can you please help me here?

    triggerRange = kiteConnect.getTriggerRange(Constants.EXCHANGE_NSE, "APOLLOTYRE", Constants.TRANSACTION_TYPE_SELL);
  • hardikdesai
    I also tried the below line and it showed be correct data with same kiteConnect object.

    lastTradedPrice = kiteConnect.getLTP(instruments).get("NSE:APOLLOTYRE").lastPrice;
  • hardikdesai
    @sujith : In the example which you provided above, the getTriggerRange method takes only 2 parameters. However in the latest KiteConnect 3, the method getTriggerRange takes 3 parameters.
  • sujith
    The trigger range method was pointing to old API. We changed it recently. You can download the latest jar file from dist directory or use the maven build.
Sign In or Register to comment.