Place a CNC limit SELL order
order_id = kite.place_order(
variety="regular",
exchange="NSE",
tradingsymbol="INFY",
transaction_type="SELL",
quantity=10,
product="CNC",
order_type="LIMIT",
price=1490.00, # will not sell below this price
validity="DAY",
)
Mirror of chapter 46 — price here is the *minimum* acceptable sale price rather than the maximum acceptable buy price.
Combine with the holdings check from chapter 45
def safe_cnc_limit_sell(kite, exchange, symbol, qty, limit_price, tick_size):
holdings = kite.holdings()
held = next((h for h in holdings if h["tradingsymbol"] == symbol), None)
if not held or held["quantity"] < qty:
raise RuntimeError(f"Insufficient settled holding to sell {qty} of {symbol}")
return kite.place_order(
variety="regular", exchange=exchange, tradingsymbol=symbol,
transaction_type="SELL", quantity=qty, product="CNC",
order_type="LIMIT", price=round_to_tick(limit_price, tick_size),
validity="DAY",
)
Using limit sells to exit at a target price without babysitting
A common pattern: after a CNC buy fills, immediately place a limit sell at your target price, and let it rest unattended.
def enter_with_target(kite, exchange, symbol, qty, target_price, tick_size):
kite.place_order(
variety="regular", exchange=exchange, tradingsymbol=symbol,
transaction_type="BUY", quantity=qty, product="CNC",
order_type="MARKET", validity="DAY",
)
# Note: this fires the sell immediately without confirming the buy filled first —
# see chapter 88 for the correct state-machine pattern that waits for fill
# confirmation before placing dependent orders.
kite.place_order(
variety="regular", exchange=exchange, tradingsymbol=symbol,
transaction_type="SELL", quantity=qty, product="CNC",
order_type="LIMIT", price=round_to_tick(target_price, tick_size),
validity="DAY",
)
The comment matters: firing the exit order before confirming the entry filled is a real bug pattern — if the buy is rejected or only partially filled, you can end up with a sell order for shares you don't hold. Chapter 88 covers the proper sequencing.