Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/anurag-roy/kiteconnect-ts/llms.txt

Use this file to discover all available pages before exploring further.

Good-Till-Triggered (GTT) orders are standing instructions that automatically place an exchange order when an instrument’s last traded price crosses a threshold you set. Unlike regular orders, GTTs persist across trading sessions until the trigger fires, the GTT expires (one year from creation), or you explicitly delete it. KiteConnect supports two trigger types: single (one price level, one order leg) and OCO (two price levels — a stop-loss below and a target above — where the first to trigger fires the order).

getGTTs

Retrieve all active and historical GTTs for your account.
const gtts = await kc.getGTTs();
gtts.forEach((g) => {
  console.log(g.id, g.type, g.status, g.condition.tradingsymbol);
});
Returns Promise<Trigger[]>. Key fields on each Trigger:
FieldTypeDescription
idnumberUnique GTT trigger ID
typestringsingle or two-leg
statusstringCurrent GTT status (see status list below)
condition.tradingsymbolstringInstrument symbol
condition.exchangestringExchange
condition.trigger_valuesnumber[]Price levels that activate the trigger
condition.last_pricenumberPrice at the time the GTT was created
ordersobject[]Order leg(s) that execute when triggered
created_atstringCreation timestamp
updated_atstringLast updated timestamp
expires_atstringExpiry timestamp (one year from creation)

getGTT

Retrieve a single GTT by its trigger ID.
const gtt = await kc.getGTT('12345');
console.log(gtt.status, gtt.condition.trigger_values);
Returns Promise<Trigger>.

placeGTT

Create a new GTT. You must pass a GTTParams object describing the trigger type, instrument, price levels, and order legs to execute.
GTT_TYPE_SINGLE requires exactly 1 value in trigger_values.
GTT_TYPE_OCO requires exactly 2 values — typically a stop-loss price (lower) and a target price (higher).

Single-leg GTT

Place a sell order automatically if the stock falls to ₹1,400.
import { KiteConnect } from 'kiteconnect-ts';

const kc = new KiteConnect({ api_key: 'YOUR_API_KEY' });
kc.setAccessToken('YOUR_ACCESS_TOKEN');

const { trigger_id } = await kc.placeGTT({
  trigger_type: kc.GTT_TYPE_SINGLE, // 'single'
  tradingsymbol: 'INFY',
  exchange: 'NSE',
  trigger_values: [1400],     // fires when LTP <= 1400
  last_price: 1500,           // current LTP at time of creation
  orders: [
    {
      transaction_type: 'SELL',
      quantity: 10,
      product: 'CNC',
      order_type: 'LIMIT',
      price: 1395,
    },
  ],
});
console.log('GTT placed, trigger_id:', trigger_id);

OCO (two-leg) GTT

Set a stop-loss at ₹900 and a target at ₹1,200. Whichever price is touched first fires the corresponding order leg.
const { trigger_id } = await kc.placeGTT({
  trigger_type: kc.GTT_TYPE_OCO, // 'two-leg'
  tradingsymbol: 'RELIANCE',
  exchange: 'NSE',
  trigger_values: [900, 1200],   // [stop-loss, target]
  last_price: 1050,
  orders: [
    {
      // Leg 1 — stop-loss sell at ₹900
      transaction_type: 'SELL',
      quantity: 5,
      product: 'CNC',
      order_type: 'LIMIT',
      price: 895,
    },
    {
      // Leg 2 — target sell at ₹1,200
      transaction_type: 'SELL',
      quantity: 5,
      product: 'CNC',
      order_type: 'LIMIT',
      price: 1195,
    },
  ],
});
Returns Promise<{ trigger_id: number }>.

GTTParams fields

trigger_type
string
required
kc.GTT_TYPE_SINGLE ('single') or kc.GTT_TYPE_OCO ('two-leg').
tradingsymbol
string
required
Exchange trading symbol of the instrument (e.g., RELIANCE, INFY).
exchange
string
required
Exchange where the instrument is listed: NSE, BSE, NFO, BFO, CDS, MCX.
trigger_values
number[]
required
List of price levels. Single GTT takes exactly 1 value; OCO takes exactly 2.
last_price
number
required
The instrument’s current last traded price at the time you create the GTT. This is used by the exchange to validate the trigger direction.
orders
object[]
required
One or two order leg objects. Each leg has:
  • transaction_typeBUY or SELL
  • quantity — number of units
  • productCNC, NRML, or MIS
  • order_typeLIMIT, MARKET, SL, or SL-M
  • price — limit price for the order leg

modifyGTT

Update an existing GTT’s trigger values or order legs.
const { trigger_id } = await kc.modifyGTT('12345', {
  trigger_type: kc.GTT_TYPE_SINGLE,
  tradingsymbol: 'INFY',
  exchange: 'NSE',
  trigger_values: [1350],   // updated trigger price
  last_price: 1500,
  orders: [
    {
      transaction_type: 'SELL',
      quantity: 10,
      product: 'CNC',
      order_type: 'LIMIT',
      price: 1345,
    },
  ],
});
Returns Promise<{ trigger_id: number }>. You must supply the full GTTParams object — the API replaces the GTT in its entirety.

deleteGTT

Permanently delete a GTT. This cannot be undone.
const { trigger_id } = await kc.deleteGTT('12345');
console.log('Deleted GTT:', trigger_id);
Returns Promise<{ trigger_id: number }>.

GTT status values

A GTT moves through these statuses during its lifecycle:
StatusDescription
activeThe GTT is live and monitoring the price condition.
triggeredThe trigger condition was met and the order was submitted to the exchange.
disabledThe GTT has been temporarily disabled by the system.
expiredThe GTT reached its one-year expiry without being triggered.
cancelledThe GTT was cancelled by the user.
rejectedThe triggered order was rejected by the exchange.
deletedThe GTT was deleted by the user via deleteGTT().
These are also available as constants on the KiteConnect instance:
kc.GTT_STATUS_ACTIVE      // 'active'
kc.GTT_STATUS_TRIGGERED   // 'triggered'
kc.GTT_STATUS_DISABLED    // 'disabled'
kc.GTT_STATUS_EXPIRED     // 'expired'
kc.GTT_STATUS_CANCELLED   // 'cancelled'
kc.GTT_STATUS_REJECTED    // 'rejected'
kc.GTT_STATUS_DELETED     // 'deleted'

Build docs developers (and LLMs) love