How to edit & cancel BO orders

thepanoramix
When I place BO orders it creates many pairs of SL & Profit orders (based on how order gets filled) . If i want to change SL price or Target price how to change it ? Do I need to edit every Order separately or is there a simpler way?
  • sujith
    Hi @thepanoramix,
    Check out example for modifying the second leg order here.
  • thepanoramix
    Thanks Sujith. I will try it.
  • billapavi
    you can refer to below code snippet
    Order orderExits = kiteConnect.getOrders();
    for(int i1 = 0; i1< orderExits.orders.size(); i1++)
    {
    Order order11 = orderExits.orders.get(i1);
    if(order11.status.contains("TRIGGER PENDING"))
    {
    System.out.println("billa 3:09 code executed "+order11.tradingSymbol);
    Map params = new HashMap<>();
    params.put("parent_order_id", order11.parentOrderId);
    Order cancelOrder = kiteConnect.cancelOrder(params, order11.orderId, order11.orderVariety);
    TestUtilities.sleep(300);
    System.out.println(cancelOrder.orderId + " is exited");
    }
    }
    above code to cancel or exit all orders at once
  • thepanoramix
    Thanks @Billapavi but kiteConntce. getOrders() will give all open orders. How to find order ids of SL and target orders of trade which i want to edit?
  • sujith
    Hi @thepanoramix,
    getOrders() will give you whole orderbook not only pending orders.
    Once you fetch orderbook, you can find the orders with parent_order_id same as the first leg bracket order.
  • thepanoramix
    Looping through all orders is not first choice solution, is there any efficient way to get it ?
  • sujith
    @thepanoramix,
    You need to filter all pending orders first. To get all pending orders, you need to find orders with status containing string 'COMPLETE', 'CANCELLE' or 'REJECTE'.
    Once you filter pending orders, you can find the orders which have parent_order_id same as first leg of bracket order.
Sign In or Register to comment.