Skip to content

PlaceGTTOrder

Place a new GTT (Good Till Triggered) order: a price-trigger that sits with the broker until LTP crosses your level, then automatically places the underlying order. Useful for setting buy/sell levels without watching the screen.

SINGLE vs OCO: Pick One

TypeUse when…TriggersOrders fired
SINGLEYou want one entry or exit at a level. Example: "Buy IDEA if it dips to 9.55" or "Sell RELIANCE if it crosses 1450".11
OCO (One-Cancels-Other)You're already in a position and want both a stoploss and a target, whichever hits first. Example: "I'm short INFY @ 1550. Stop me out at 1480, take profit at 1620."21 of 2 (the other is auto-cancelled)

In SINGLE there is no second leg and no automatic cancel: once your one trigger fires and the order is placed, the GTT is finished.

How to Choose triggerprice_sl vs triggerprice_tg (SINGLE only)

For SINGLE, exactly one of these two fields is your trigger price; set the other to 0. Pick based on where your trigger sits relative to LTP. This also matches the leg name the broker assigns internally:

FieldTrigger sits…Typical intent
triggerprice_slbelow current LTPSELL stop-loss · BUY-on-dip · BUY-the-fall
triggerprice_tgabove current LTPBUY breakout · SELL-at-target · SELL-the-rise

For OCO, you always send both: triggerprice_sl (the lower trigger, your stoploss) and triggerprice_tg (the higher trigger, your target).

Note on naming. In SINGLE, triggerprice_sl / triggerprice_tg are just the trigger price, the generic "price at which the order is triggered". The _sl / _tg suffix is only a directional hint (sits below / above LTP); SINGLE has no stoploss leg. In OCO, the suffix becomes a real role: triggerprice_sl is the stoploss-leg trigger and triggerprice_tg is the target-leg trigger.

Endpoint URL

http
Local Host   :  POST http://127.0.0.1:5000/api/v1/placegttorder
Ngrok Domain :  POST https://<your-ngrok-domain>.ngrok-free.app/api/v1/placegttorder
Custom Domain:  POST https://<your-custom-domain>/api/v1/placegttorder

Sample API Request (SINGLE): "Buy IDEA if it dips to 9.55, place a LIMIT order at 9.50"

json
{
  "apikey": "<your_app_apikey>",
  "strategy": "My GTT Strategy",
  "trigger_type": "SINGLE",
  "exchange": "NSE",
  "symbol": "IDEA",
  "action": "BUY",
  "product": "CNC",
  "quantity": 1,
  "pricetype": "LIMIT",
  "price": 9.50,
  "triggerprice_sl": 9.55,
  "triggerprice_tg": 0,
  "stoploss": null,
  "target": null
}

LTP is currently above 9.55 → trigger sits below LTP → use triggerprice_sl.

Sample cURL Request

bash
curl -X POST http://127.0.0.1:5000/api/v1/placegttorder \
  -H 'Content-Type: application/json' \
  -d '{
  "apikey": "<your_app_apikey>",
  "strategy": "My GTT Strategy",
  "trigger_type": "SINGLE",
  "exchange": "NSE",
  "symbol": "IDEA",
  "action": "BUY",
  "product": "CNC",
  "quantity": 1,
  "pricetype": "LIMIT",
  "price": 9.50,
  "triggerprice_sl": 9.55,
  "triggerprice_tg": 0,
  "stoploss": null,
  "target": null
}'

Sample API Response

json
{
  "status": "success",
  "trigger_id": "23132604291205"
}

Sample API Request (SINGLE): "Buy RELIANCE at MARKET if it breaks above 1450"

json
{
  "apikey": "<your_app_apikey>",
  "strategy": "My GTT Strategy",
  "trigger_type": "SINGLE",
  "exchange": "NSE",
  "symbol": "RELIANCE",
  "action": "BUY",
  "product": "CNC",
  "quantity": 1,
  "pricetype": "MARKET",
  "price": 0,
  "triggerprice_sl": 0,
  "triggerprice_tg": 1450,
  "stoploss": null,
  "target": null
}

LTP is currently below 1450 → trigger sits above LTP → use triggerprice_tg. price=0 because pricetype is MARKET.

Sample API Request (OCO): "Bracket my INFY short, stop at 1480, take profit at 1620"

json
{
  "apikey": "<your_app_apikey>",
  "strategy": "Bracket OCO",
  "trigger_type": "OCO",
  "exchange": "NSE",
  "symbol": "INFY",
  "action": "SELL",
  "product": "CNC",
  "quantity": 5,
  "pricetype": "LIMIT",
  "price": 0,
  "triggerprice_sl": 1480,
  "stoploss": 1478,
  "triggerprice_tg": 1620,
  "target": 1622
}

price=0 because OCO uses per-leg limit prices: stoploss (the SL leg's limit) and target (the target leg's limit).

Sample API Response (OCO)

json
{
  "status": "success",
  "trigger_id": "23132604291213"
}

Parameters Description

ParametersDescriptionMandatory/OptionalDefault Value
apikeyTradeboard API key (string)Mandatory-
strategyStrategy identifier (string, used as broker correlation id where supported)Mandatory-
trigger_typeSINGLE or OCO (string)Mandatory-
exchangeAny value in the shared VALID_EXCHANGES list (string)Mandatory-
symbolTrading symbol in Tradeboard format (string)Mandatory-
actionBUY or SELL (string). For OCO, applies to both legs.Mandatory-
productCNC (equity delivery) or NRML (F&O overnight). MIS is not supported because GTTs can sit for days. (string)Mandatory-
quantityOrder quantity. Integer for equity/F&O; fractional float allowed for crypto (number).Mandatory-
pricetypeLIMIT or MARKET (string)OptionalLIMIT
priceSINGLE only. Limit price of the child order. Send 0 when pricetype=MARKET. Ignored for OCO. (float)Mandatory-
triggerprice_slTrigger price below LTP. SINGLE: use this OR triggerprice_tg. OCO: required (the stoploss-leg trigger). (float)Conditional0
triggerprice_tgTrigger price above LTP. SINGLE: use this OR triggerprice_sl. OCO: required (the target-leg trigger). (float)Conditional0
stoplossOCO only. Limit price for the stoploss leg's child order. Ignored for SINGLE. (float, null, or "")Conditionalnull
targetOCO only. Limit price for the target leg's child order. Ignored for SINGLE. (float, null, or "")Conditionalnull
expires_atRequested expiry for the trigger, passed through to brokers that support one. Brokers without an explicit expiry ignore it. (string or null)Optionalnull

Unlike most Tradeboard request schemas, PlaceGTTOrderSchema sets unknown = EXCLUDE, so an unrecognized field is dropped rather than rejected with HTTP 400. Do not rely on that to smuggle broker-specific parameters through: dropped fields never reach the broker. last_price in particular is fetched server-side and is discarded if you send it.

Trigger Field Rules

trigger_typeWhat you must sendConstraint
SINGLEexactly one of triggerprice_sl / triggerprice_tg (>0); the other = 0price is the child order's limit; send 0 for MARKET.
OCOall four: triggerprice_sl, stoploss, triggerprice_tg, target (all >0)triggerprice_sl < triggerprice_tg. Both legs share action, quantity, product.

Response Fields

FieldTypeDescription
statusstring"success" or "error"
trigger_idstringUnique trigger ID from broker (on success). Save this to modify or cancel later.
messagestringError message (on error)

Notes

  • Numeric fields (quantity, price, triggerprice_sl, triggerprice_tg, stoploss, target) are JSON floats. Empty strings ("") for stoploss/target/triggerprice_sl/triggerprice_tg are also accepted and coerced to null/0.
  • last_price is fetched server-side from the broker's quotes endpoint. You don't need to send it.
  • MARKET handling: some brokers' GTT APIs only accept LIMIT child orders. When that's the case, Tradeboard automatically converts a MARKET request into a Market-Price-Protected LIMIT (a slab-based buffer around LTP for SINGLE, or around each leg's trigger for OCO) so the submitted pricetype=MARKET works uniformly across brokers.
  • OCO direction: stoploss-leg trigger must be below target-leg trigger (triggerprice_sl < triggerprice_tg). The action (BUY or SELL) applies to both legs.
  • Analyzer (sandbox) mode places the GTT in the sandbox instead of at the broker: the response carries "mode": "analyze" and a GTT-... trigger id, margin is reserved at placement, and the trigger fires against live LTP exactly as it would at the broker, placing a sandbox order. See GTTOrderBook for how to read what fired.
  • Symbol format:
    • Equity: RELIANCE
    • Futures: NIFTY30JAN25FUT
    • Options: NIFTY30JAN2525000CE

Error Scenarios

ErrorCause
triggerprice_sl: SINGLE GTT requires a positive triggerprice_sl or triggerprice_tgSINGLE without any trigger price
triggerprice_sl: Stoploss trigger must be less than target triggerOCO with triggerprice_sl >= triggerprice_tg
triggerprice_sl/stoploss/triggerprice_tg/target: Required for OCOOCO missing one of the four required fields
Quantity must be a positive numberquantity ≤ 0
GTT supports only CNC (delivery) or NRML (overnight F&O); MIS is intraday-only.product=MIS submitted
Fractional quantity is not allowed for non-crypto exchangesNon-integer qty on equity/F&O
GTT orders are not supported for broker 'X' yet (501)Broker doesn't ship a gtt_api module

Back to: API Documentation