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?
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
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, 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.
Check out example for modifying the second leg order here.
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
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.
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.