GTT - Good Till Triggered orders

The GTT APIs allow you to place, modify and manage GTTs.

type endpoint  
POST /gtt/triggers Place a GTT order
GET /gtt/triggers Retrieve a list of all orders
GET /gtt/triggers/:id Retrieve an individual order
PUT /gtt/triggers/:id Modify an active GTT order
DELETE /gtt/triggers/:id Delete an active GTT order

Placing orders

curl https://api.kite.trade/gtt/triggers \
    -H 'X-Kite-Version: 3' \
    -H 'Authorization: token api_key:access_token' \
    -d 'type=single' \
    -d 'condition={"exchange":"NSE", "tradingsymbol":"INFY", "trigger_values":[702.0], "last_price": 798.0}' \
    -d 'orders=[{"exchange":"NSE", "tradingsymbol": "INFY", "transaction_type": "BUY", "quantity": 1, "order_type": "LIMIT","product": "CNC", "price": 702.5}]'
{
    "status":"success",
    "data":{
        "trigger_id":1337
    }
}

Order parameters

parameter  
type The type of GTT order
condition The condition parameters (json object)
orders The orders to be placed (json array).

Condition parameters

The API expects the following parameters encoded as json in the condition post parameter.

parameter  
exchange Name of the exchange
tradingsymbol Trading symbol of the instrument
trigger_values Trigger values (json array)
last_price Last price of the instrument at the time of order placement

Orders list

The API expects a list of orders encoded as a json array. The index of the order is used by API to determine which order to execute when a trigger value is reached.

The order object inside the list expect the following parameters.

parameter  
exchange Name of the exchange
tradingsymbol Trading symbol of the instrument
transaction_type BUY or SELL
quantity Quantity to transact
order_type LIMIT
product Margin product to use for the order
price The min or max price to execute the order at (for LIMIT orders)

Sample order:

{
    "exchange":"NSE", 
    "tradingsymbol": "INFY", 
    "transaction_type": "BUY", 
    "quantity": 1, 
    "order_type": "LIMIT",
    "product": "CNC", 
    "price": 702.5
}

Type

The GTT API supports the following type of GTT orders. The type of the GTT order is used to parse the condition passed to it. The following types are supported by GTT API at the moment.

single

The single leg order type expects a single trigger value, and executes the first order that is in the orders array when the trigger value is reached.

Sample condition:

{
    "exchange":"NSE", 
    "tradingsymbol":"INFY", 
    "trigger_values":[702.0], 
    "last_price": 798.0
}

Note

This order type expects only one trigger value inside the trigger_values

Sample orders:

[
    {
        "exchange":"NSE", 
        "tradingsymbol": "INFY", 
        "transaction_type": "BUY", 
        "quantity": 1, 
        "order_type": "LIMIT",
        "product": "CNC", 
        "price": 702.5
    }
]
two-leg

The two-leg order implements the OCO (One Cancels Other) order. It expects two trigger values and executes the corresponding order in the orders array when either of the trigger value is reached, the other order is dormant.

Sample condition:

{
    "exchange":"NSE", 
    "tradingsymbol":"INFY", 
    "trigger_values":[702.0, 798.0], 
    "last_price": 742.0
}

Note

This order type expects two trigger value inside the trigger_values

Sample orders:

[
    {
        "exchange":"NSE", 
        "tradingsymbol": "INFY", 
        "transaction_type": "SELL", 
        "quantity": 1, 
        "order_type": "LIMIT",
        "product": "CNC", 
        "price": 702.5
    },
    {  
        "exchange":"NSE", 
        "tradingsymbol": "INFY", 
        "transaction_type": "SELL", 
        "quantity": 1, 
        "order_type": "LIMIT",
        "product": "CNC", 
        "price": 798.5
    }
]

Retrieving orders

Active GTT orders and GTTs in others states (last 7 days) can be obtained by a GET API call to the /triggers/gtt endpoint.

curl  "https://api.kite.trade/gtt/triggers" \
    -H "X-Kite-Version: 3" \
    -H "Authorization: token api_key:access_token" 
{
    "status": "success",
    "data": [
        {
            "id": 112127,
            "user_id": "XX0000",
            "parent_trigger": null,
            "type": "single",
            "created_at": "2019-09-12 13:25:16",
            "updated_at": "2019-09-12 13:25:16",
            "expires_at": "2020-09-12 13:25:16",
            "status": "active",
            "condition": {
                "exchange": "NSE",
                "last_price": 798,
                "tradingsymbol": "INFY",
                "trigger_values": [
                    702
                ],
                "instrument_token": 408065
            },
            "orders": [
                {
                    "account_id": "",
                    "parent_order_id": "",
                    "exchange": "NSE",
                    "tradingsymbol": "INFY",
                    "validity": "",
                    "product": "CNC",
                    "order_type": "LIMIT",
                    "transaction_type": "BUY",
                    "quantity": 1,
                    "disclosed_quantity": 0,
                    "price": 702.5,
                    "trigger_price": 0,
                    "ltp_atp": "",
                    "squareoff_abs_tick": "",
                    "stoploss_abs_tick": "",
                    "squareoff": 0,
                    "stoploss": 0,
                    "trailing_stoploss": 0,
                    "meta": "",
                    "guid": "",
                    "result": null
                }
            ],
            "meta": {}
        },
        {
            "id": 105099,
            "user_id": "XX0000",
            "parent_trigger": null,
            "type": "two-leg",
            "created_at": "2019-09-09 15:13:22",
            "updated_at": "2019-09-09 15:15:08",
            "expires_at": "2020-01-01 12:00:00",
            "status": "triggered",
            "condition": {
                "exchange": "NSE",
                "last_price": 102.6,
                "tradingsymbol": "RAIN",
                "trigger_values": [
                    102.0,
                    103.7
                ],
                "instrument_token": 3926273
            },
            "orders": [
                {
                    "account_id": "",
                    "parent_order_id": "",
                    "exchange": "NSE",
                    "tradingsymbol": "RAIN",
                    "validity": "",
                    "product": "CNC",
                    "order_type": "LIMIT",
                    "transaction_type": "SELL",
                    "quantity": 1,
                    "disclosed_quantity": 0,
                    "price": 1,
                    "trigger_price": 0,
                    "ltp_atp": "",
                    "squareoff_abs_tick": "",
                    "stoploss_abs_tick": "",
                    "squareoff": 0,
                    "stoploss": 0,
                    "trailing_stoploss": 0,
                    "meta": "",
                    "guid": "",
                    "result": null
                },
                {
                    "account_id": "",
                    "parent_order_id": "",
                    "exchange": "NSE",
                    "tradingsymbol": "RAIN",
                    "validity": "",
                    "product": "CNC",
                    "order_type": "LIMIT",
                    "transaction_type": "SELL",
                    "quantity": 1,
                    "disclosed_quantity": 0,
                    "price": 1,
                    "trigger_price": 0,
                    "ltp_atp": "",
                    "squareoff_abs_tick": "",
                    "stoploss_abs_tick": "",
                    "squareoff": 0,
                    "stoploss": 0,
                    "trailing_stoploss": 0,
                    "meta": "",
                    "guid": "",
                    "result": {
                        "account_id": "XX0000",
                        "parent_order_id": "",
                        "exchange": "NSE",
                        "tradingsymbol": "RAIN",
                        "validity": "DAY",
                        "product": "CNC",
                        "order_type": "LIMIT",
                        "transaction_type": "SELL",
                        "quantity": 1,
                        "disclosed_quantity": 0,
                        "price": 1,
                        "trigger_price": 0,
                        "ltp_atp": "LTP",
                        "squareoff_abs_tick": "absolute",
                        "stoploss_abs_tick": "absolute",
                        "squareoff": 0,
                        "stoploss": 0,
                        "trailing_stoploss": 0,
                        "meta": "{\"app_id\":12617,\"gtt\":105099}",
                        "guid": "",
                        "timestamp": "2019-09-09 15:15:08",
                        "triggered_at": 103.7,
                        "order_result": {
                            "status": "failed",
                            "order_id": "",
                            "rejection_reason": "Your order price is lower than the current lower circuit limit of 70.65. Place an order within the daily range."
                        }
                    }
                }
            ],
            "meta": null
        }
    ]
}

Retrieve order

Given a GTT order ID, the GET API call to this endpoint will return details of the order irrespective of the age or status of the GTT order.

curl https://api.kite.trade/gtt/triggers/105099 \                                       
    -H 'X-Kite-Version: 3' \
    -H 'Authorization: token api_key:access_token'
{
    "status": "success",
    "data": {
        "id": 105099,
        "user_id": "XX0000",
        "parent_trigger": null,
        "type": "two-leg",
        "created_at": "2019-09-09 15:13:22",
        "updated_at": "2019-09-09 15:15:08",
        "expires_at": "2020-01-01 12:00:00",
        "status": "triggered",
        "condition": {
            "exchange": "NSE",
            "last_price": 102.6,
            "tradingsymbol": "RAIN",
            "trigger_values": [
                102.0,
                103.7
            ],
            "instrument_token": 3926273
        },
        "orders": [
            {
                "account_id": "",
                "parent_order_id": "",
                "exchange": "NSE",
                "tradingsymbol": "RAIN",
                "validity": "",
                "product": "CNC",
                "order_type": "LIMIT",
                "transaction_type": "SELL",
                "quantity": 1,
                "disclosed_quantity": 0,
                "price": 1,
                "trigger_price": 0,
                "ltp_atp": "",
                "squareoff_abs_tick": "",
                "stoploss_abs_tick": "",
                "squareoff": 0,
                "stoploss": 0,
                "trailing_stoploss": 0,
                "meta": "",
                "guid": "",
                "result": null
            },
            {
                "account_id": "",
                "parent_order_id": "",
                "exchange": "NSE",
                "tradingsymbol": "RAIN",
                "validity": "",
                "product": "CNC",
                "order_type": "LIMIT",
                "transaction_type": "SELL",
                "quantity": 1,
                "disclosed_quantity": 0,
                "price": 1,
                "trigger_price": 0,
                "ltp_atp": "",
                "squareoff_abs_tick": "",
                "stoploss_abs_tick": "",
                "squareoff": 0,
                "stoploss": 0,
                "trailing_stoploss": 0,
                "meta": "",
                "guid": "",
                "result": {
                    "account_id": "XX0000",
                    "parent_order_id": "",
                    "exchange": "NSE",
                    "tradingsymbol": "RAIN",
                    "validity": "DAY",
                    "product": "CNC",
                    "order_type": "LIMIT",
                    "transaction_type": "SELL",
                    "quantity": 1,
                    "disclosed_quantity": 0,
                    "price": 1,
                    "trigger_price": 0,
                    "ltp_atp": "LTP",
                    "squareoff_abs_tick": "absolute",
                    "stoploss_abs_tick": "absolute",
                    "squareoff": 0,
                    "stoploss": 0,
                    "trailing_stoploss": 0,
                    "meta": "{\"app_id\":12617,\"gtt\":105099}",
                    "guid": "",
                    "timestamp": "2019-09-09 15:15:08",
                    "triggered_at": 103.7,
                    "order_result": {
                        "status": "failed",
                        "order_id": "",
                        "rejection_reason": "Your order price is lower than the current lower circuit limit of 70.65. Place an order within the daily range."
                    }
                }
            }
        ],
        "meta": null
    }
}

Modify order

To modify a GTT order you need to send a PUT call with updated parameters.

curl --request PUT https://api.kite.trade/gtt/triggers/1337 \
    -H 'X-Kite-Version: 3' \
    -H 'Authorization: token api_key:access_token' \
    -d 'type=single' \
    -d 'condition={"exchange":"NSE", "tradingsymbol":"INFY", "trigger_values":[701.0], "last_price": 798.0}' \
    -d 'orders=[{"exchange":"NSE", "tradingsymbol": "INFY", "transaction_type": "BUY", "quantity": 1, "order_type": "LIMIT","product": "CNC", "price": 702.5}]'
{
    "status":"success",
    "data":{
        "trigger_id":1337
    }
}

Delete order

curl --request DELETE https://api.kite.trade/gtt/triggers/1337 \
    -H 'X-Kite-Version: 3' \
    -H 'Authorization: token api_key:access_token' \
{
    "status":"success",
    "data":{
        "trigger_id":1337
    }
}