cover order understanding and API usage confirmation

bk18
Hi,

I request the group here to confirm my understanding of cover order and the API use. In a cover order, you provide the price and the trigger price, which i assume is basically the stop loss price. So assuming the current price of Nifty is 10550 and expecting to increase further, i place a long(buy) on Nifty using POST call as per the API documentation. So the prarameters for the API, price is 10550 and trigger price is 10535(stop loss). The order is successful(i get the response as success and check the order is placed successfully using GET API). As expected Nifty increases and it is now at 10585. So now, i wish to square off my position and with this the stop loss order would be automatically cancelled. But what API do i need to use now to square off? Do i need to use the same POST API with sell action or use PUT API with the order id?

--Thanks.
  • bk18
    Thanks @sujith. Can you let me know the signature of cancelOrder method? The method takes 3 parameters. I assume cancelling CO and BO are the same.

    --Thanks.
  • sujith
    You can check out example here.
  • bk18
    Thanks @sujith. Clicking on the link gets me

    public void cancelOrder(KiteConnect kiteConnect) throws KiteException, IOException {
    // Order modify request will return order model which will contain only order_id.
    // Cancel order will return order model which will only have orderId.
    Order order2 = kiteConnect.cancelOrder("180116000727266", Constants.VARIETY_REGULAR);
    System.out.println(order2.orderId);
    }

    public void exitBracketOrder(KiteConnect kiteConnect) throws KiteException, IOException {
    Order order = kiteConnect.cancelOrder("180116000812153","180116000798058", Constants.VARIETY_BO);
    System.out.println(order.orderId);
    }

    On the cancelOrder, i presume the first order id, second is trade id and third is type(for me it would be VARIETY_CO. Can you pls confirm?

    Note: All i am trying is to cancel the pending SL order in a CO.

    --Thanks.
  • sujith
    @bk18,
    Please go through API and java documentation, you can find the links here.
  • bk18
    Thanks @sujith. I got it from the java documentation but i have tagged this to general API rather than java. So from the connect docs, using curl, i see this as the way.

    curl --request DELETE \
    "https://api.kite.trade/orders/co/151220000000000?parent_order_id=151210000000000" \
    -H "X-Kite-Version: 3" \
    -H "Authorization: token api_key:access_token" \

    Exactly the same from the docs except "bo" changed to "co".

    --Thanks.
  • sujith
    Yes, you need to send second leg order id and parent order id for bo/co exit.
Sign In or Register to comment.