Place a GTT order

GTT (Good Till Triggered) orders live on the broker's servers, not the exchange — they watch price and place a real order only when triggered, and can stay active for up to a year, surviving your bot being offline.

gtt_id = kite.place_gtt(
    trigger_type=kite.GTT_TYPE_SINGLE,
    tradingsymbol="INFY",
    exchange="NSE",
    trigger_values=[1450.00],
    last_price=1478.90,          # current LTP, required for validation
    orders=[{
        "transaction_type": "SELL",
        "quantity": 10,
        "order_type": "LIMIT",
        "product": "CNC",
        "price": 1449.50,
    }],
)

OCO-style GTT: target AND stop-loss as one trigger set

gtt_id = kite.place_gtt(
    trigger_type=kite.GTT_TYPE_OCO,
    tradingsymbol="INFY",
    exchange="NSE",
    trigger_values=[1450.00, 1520.00],   # [stop-loss trigger, target trigger]
    last_price=1478.90,
    orders=[
        {"transaction_type": "SELL", "quantity": 10, "order_type": "LIMIT", "product": "CNC", "price": 1449.50},
        {"transaction_type": "SELL", "quantity": 10, "order_type": "LIMIT", "product": "CNC", "price": 1519.50},
    ],
)

This is a native OCO (one-cancels-other) — whichever trigger hits first places its order and automatically cancels the other. This is the built-in solution to the manual OCO problem raised in chapter 55.

Why GTT beats a bot-managed SL/target for unattended, long-horizon positions

A GTT lives on Zerodha's servers independent of your bot's uptime — if your bot crashes, loses internet, or the VPS reboots, a GTT stop-loss still fires. A bot-managed SL-M order (chapter 51) placed on the exchange also survives your bot going down (it's already resting on the exchange), but a *planned but not-yet-placed* stop only exists in your bot's logic — GTT removes that dependency entirely for swing/positional trades.

Managing GTTs

kite.get_gtts()                          # list all active GTTs
kite.get_gtt(trigger_id=gtt_id)          # one GTT's details
kite.modify_gtt(trigger_id=gtt_id, ...)  # same params as place_gtt
kite.delete_gtt(trigger_id=gtt_id)

Next: 060 — Multi-leg option orders