Modify a pending order

Only orders in a non-terminal state (OPEN, TRIGGER PENDING) can be modified — you're changing a resting order, not resubmitting a new one.

kite.modify_order(
    variety="regular",
    order_id=order_id,
    price=1472.50,       # new limit price
    quantity=15,           # optionally change quantity too
)

For an SL/SL-M order, modify trigger_price instead (or alongside price):

kite.modify_order(
    variety="regular",
    order_id=order_id,
    trigger_price=1448.00,
)

Common use case: trailing a stop-loss manually

def trail_stop_loss(kite, order_id: str, current_price: float, trail_distance: float, tick_size: float):
    new_trigger = round_to_tick(current_price - trail_distance, tick_size)
    order = next(o for o in kite.orders() if o["order_id"] == order_id)
    if new_trigger > order["trigger_price"]:   # only ever move SL in the favorable direction
        kite.modify_order(variety="regular", order_id=order_id, trigger_price=new_trigger)

The if new_trigger > order["trigger_price"] guard matters — a trailing stop should only ratchet in the direction that locks in more profit, never loosen back. Skipping this check is a real bug: on a noisy price series, a naive "always modify to current_price - distance" would move the stop backward on a pullback, undoing the trail.

You cannot modify quantity below what's already filled

If an order is partially filled (chapter 56), attempting to modify its quantity below the already-filled amount is rejected — you can only modify the *pending* remainder.

Modify is not atomic with your check-then-act logic

Between checking current order state and calling modify_order(), the order could fill or get cancelled by the exchange. Handle OrderException on the modify call and re-check status afterward rather than assuming the modify succeeded just because the call didn't raise.

try:
    kite.modify_order(variety="regular", order_id=order_id, price=new_price)
except OrderException as e:
    logging.warning(f"Modify failed, likely already filled/cancelled: {e}")

Next: 055 — Cancel a pending order