Place a stop-loss-market (SL-M) order
SL-M triggers at trigger_price and becomes a market order — no price field, no limit ambiguity. This guarantees a fill, at the cost of no control over the exact exit price.
order_id = kite.place_order(
variety="regular",
exchange="NSE",
tradingsymbol="INFY",
transaction_type="SELL",
quantity=10,
product="MIS",
order_type="SL-M",
trigger_price=1450.00,
validity="DAY",
)
SL vs SL-M — the actual tradeoff, stated plainly
SL | SL-M | |
|---|---|---|
| Guarantees a fill once triggered | No | Yes |
| Controls exit price | Yes (approximately) | No |
| Risk in a fast gap | May not fill at all | Fills, possibly far worse than trigger price |
For most risk-management stop-losses, SL-M is the safer default — the entire point of a stop-loss is capping loss, and an unfilled SL order in a fast-moving adverse market defeats that purpose completely. A worse-than-expected fill from SL-M is still a bounded, known-direction loss; an unfilled SL is unbounded.
def place_protective_stop(kite, exchange, symbol, qty, trigger_price, product="MIS", exit_side="SELL"):
return kite.place_order(
variety="regular", exchange=exchange, tradingsymbol=symbol,
transaction_type=exit_side, quantity=qty, product=product,
order_type="SL-M", trigger_price=trigger_price, validity="DAY",
)
Trigger price must respect exchange-mandated minimum distance
Exchanges enforce a minimum gap between trigger_price and the current LTP for SL/SL-M orders (to prevent instant-trigger orders that behave like disguised market orders) — placing a trigger too close to current price gets rejected. Check the rejection message (chapter 57) rather than assuming any trigger price is valid.
Always place the SL-M immediately after entry fills, never as an afterthought
If your bot's logic path is "enter position, then later decide on a stop," there's a window where the position sits completely unprotected. Chapter 88's state machine pattern places the protective order as part of the same atomic step as confirming entry fill — not a separate, delayed step.