How to modify SL iceberg orders?

akhilesh_singla
Which one of the below two functions would work fine for modifying SL iceberg orders?
def function_1(parent_order_id, price):
try:
kite.modify_order(
variety="iceberg",
order_id=parent_order_id,
price=price,
trigger_price=price
)
return True
except Exception as e:
print(f"Error modifying SL: {e}")
return False

def function_2(parent_order_id, price):
try:
orders = kite.orders()
active_states = {"OPEN", "TRIGGER PENDING"}

for o in orders:
if o.get("parent_order_id") == parent_order_id and o["status"] in active_states:
kite.modify_order(
variety=o["variety"],
order_id=o["order_id"],
price=price,
trigger_price=price
)
return True
except Exception as e:
print_log(f"Error modifying SL: {e}")
return False

Concern with function_1() is whether it will perform well when one leg of SL is executed and others are in pending state. Not sure about the limitations of function_2()

  • salim_chisty
    We don't recommend a specific coding approach. Attempting to modify an order that has already been rejected or completed will result in an error; therefore, to ensure reliable execution and avoid unnecessary exceptions, it is recommended to validate the current order status and proceed with modification requests only for orders in the OPEN or TRIGGER PENDING state.
Sign In or Register to comment.