Need process for modifying Cover Order (CO) - Python - Order cannot be modified as it is being proc

ashxos
Hi,

Im not getting how to modify the Stoploss for Cover Order via python code.
I get error when i try to modify order via below code. Is there any alternate method to modify stoploss for CO Order?

Error : kiteconnect.exceptions.InputException: Order cannot be modified as it is being processed. Try later.
Code :
something = kite.modify_order(variety = "co",
order_id = 210716201586018,
trigger_price = SL_price
)
But when I put the order ID as 210716201586019, then order gets fulfilled and SL gets modified.
Is there any method by which I can modify CO order based on the parent order ID 210716201586018 ?

Order Details :
{'placed_by': 'NU1042', 'order_id': '210716201586018', 'exchange_order_id': '1300000007754396', 'parent_order_id': None, 'status': 'COMPLETE', 'status_message': None, 'status_message_raw': None, 'order_timestamp': datetime.datetime(2021, 7, 16, 11, 25, 45), 'exchange_update_timestamp': '2021-07-16 11:25:45', 'exchange_timestamp': datetime.datetime(2021, 7, 16, 11, 25, 45), 'variety': 'co', 'exchange': 'NSE', 'tradingsymbol': 'SAIL', 'instrument_token': 758529, 'order_type': 'MARKET', 'transaction_type': 'BUY', 'validity': 'DAY', 'product': 'CO', 'quantity': 1, 'disclosed_quantity': 0, 'price': 0, 'trigger_price': 115, 'average_price': 127.3, 'filled_quantity': 1, 'pending_quantity': 0, 'cancelled_quantity': 0, 'market_protection': 0, 'meta': {}, 'tag': None, 'guid': '35502X8BzBfv2NmAuJ'},

{'placed_by': 'NU1042', 'order_id': '210716201586019', 'exchange_order_id': '1300000007754397', 'parent_order_id': '210716201586018', 'status': 'TRIGGER PENDING', 'status_message': None, 'status_message_raw': None, 'order_timestamp': datetime.datetime(2021, 7, 16, 11, 25, 45), 'exchange_update_timestamp': '2021-07-16 11:25:45', 'exchange_timestamp': datetime.datetime(2021, 7, 16, 11, 25, 45), 'variety': 'co', 'exchange': 'NSE', 'tradingsymbol': 'SAIL', 'instrument_token': 758529, 'order_type': 'SL-M', 'transaction_type': 'SELL',
'validity': 'DAY', 'product': 'CO', 'quantity': 1, 'disclosed_quantity': 0, 'price': 0, 'trigger_price': 115, 'average_price': 0, 'filled_quantity': 0, 'pending_quantity': 1, 'cancelled_quantity': 0, 'market_protection': 0, 'meta': {}, 'tag': None, 'guid': '1626414945-358459-NU1042-CO'}
  • sujith
    A cover order doesn't have a trigger price for an entry order. The entry type allowed for cover order is only market and limit.
    If you are modifying trigger price then it has to be done for second leg order not for entry order.
  • ashxos
    Dear Sujith,

    I got the point that the Entry Order can not be modified.
    As we submit cover order, return ID which we get is of Entry Order. Which we can not use for modifying the CO.

    There is long process to find out the Second Leg order ID.
    I have wrote below code for getting the 2nd leg order ID now.
    1. Im getting all orders
    2. Im searching for Parent order ID which is matching with provided order ID
    3. Im returning the 2nd Leg Order ID.

    Is there any other mechanism available other than below method.
    def Zerodha_get_SL_OrderID(order_id):
    All_Kite_Orders_for_Today = kite.orders()
    for i in All_Kite_Orders_for_Today:
    parent_order_ID = i['parent_order_id']
    if str(parent_order_ID) == str(order_id):
    SL_Order_ID = i['order_id']
    return SL_Order_ID
  • sujith
    This is the correct process. We recommend the same to users.
  • ashxos
    Thanks Sujith!
Sign In or Register to comment.