Skip to content

Add GTT

POST /gttoco/addGtt

GTT (Good Till Triggered) is a feature that allows users to place buy or sell orders of any stock at market or limit price. These orders are executed (triggered) once the market price of the stock reaches your desired price i.e the price you mentioned in the GTT Order. Read More....

In the BFO exchange, only SENSEX and BANKEX trades are allowed.

Parameter

NameTypeRequiredDescription
exchangestringtrueThe stock exchange where the order will be placed. Valid values: BSE, NSE, NFO, BFO, MCX, CDS, MFO. Default is NSE if not provided. For trading with BSE, NFO, BFO, CDS, MFO, and MCX, the exchange is mandatory.
symbolNamestringtrueSymbol name of the scrip. For Equity, enter the SymbolName of the scrip. For Derivatives, enter the TradingSymbol of the scrip.
transactionTypestringtrueDetermines whether the order is a buy or sell transaction.
quantitystringtrueDefines the number of units or shares of the asset to be bought or sold.
productTypestringtrueProduct type of the order. Can be CNC, NRML. The valid product type for F&O (Futures and Options) is NRML.
orderTypestringtrueType of order placed. Can be MKT (Market Order) or L (Limit Order).
triggerPricestringtrueRepresents the market-entry price level for the placed order.
limitPricestringtrueRequired for L (Limit) orders. This is the price at which the order is executed in the market.
marketProtectionstringtrueRequired for market orders. Default is set to 3% to protect the order from potential market losses.

Sample Request Body

json
requestBody={
  "exchange": "NFO",
  "symbolName": "WIPRO24JUN585PE",
  "transactionType": "BUY",
  "quantity": "1500",
  "productType": "NRML",
  "orderType": "L",
  "triggerPrice": "1180",
  "limitPrice": "1160"
}
json
requestBody={
  "exchange": "BFO",
  "symbolName": "SENSEX502441823950PE",
  "transactionType": "BUY",
  "quantity": "1",
  "productType": "NRML",
  "orderType": "MKT",
  "triggerPrice": "12",
  "marketProtection" : ""
}

Live trading endpoint

This sample sends a real request against your trading account. Replace <SESSION_TOKEN> and review every field before running — Samco does not provide a sandbox, and any successful call affects live positions and balances.

Sample Code

bash
curl -X POST 'https://tradeapi.samco.in/gttoco/addGtt' \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'x-session-token: <SESSION_TOKEN>' \
  -d '{"exchange":"NFO","symbolName":"WIPRO24JUN585PE","transactionType":"BUY","quantity":"1500","productType":"NRML","orderType":"L","triggerPrice":"1180","limitPrice":"1160"}'
java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class Sample {
  public static void main(String[] args) throws Exception {
    String requestBody = """
        {
          "exchange": "NFO",
          "symbolName": "WIPRO24JUN585PE",
          "transactionType": "BUY",
          "quantity": "1500",
          "productType": "NRML",
          "orderType": "L",
          "triggerPrice": "1180",
          "limitPrice": "1160"
        }
        """;

    HttpClient client = HttpClient.newHttpClient();

    HttpRequest request = HttpRequest.newBuilder()
        .uri(URI.create("https://tradeapi.samco.in/gttoco/addGtt"))
        .header("Content-Type", "application/json")
        .header("Accept", "application/json")
        .header("x-session-token", "<SESSION_TOKEN>")
        .POST(HttpRequest.BodyPublishers.ofString(requestBody))
        .build();

    HttpResponse<String> response =
        client.send(request, HttpResponse.BodyHandlers.ofString());
    System.out.println(response.body());
  }
}
js
(async () => {
  const headers = {
    'Content-Type': 'application/json',
    'Accept': 'application/json',
    'x-session-token': '<SESSION_TOKEN>',
  };

  const requestBody = {
    exchange: "NFO",
    symbolName: "WIPRO24JUN585PE",
    transactionType: "BUY",
    quantity: "1500",
    productType: "NRML",
    orderType: "L",
    triggerPrice: "1180",
    limitPrice: "1160"
  };

  const response = await fetch('https://tradeapi.samco.in/gttoco/addGtt', {
    method: 'POST',
    headers,
    body: JSON.stringify(requestBody),
  });

  const data = await response.json();
  console.log(data);
})();
py
import requests
import json

headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/json',
  'x-session-token': '<SESSION_TOKEN>',
}

requestBody = {
  "exchange": "NFO",
  "symbolName": "WIPRO24JUN585PE",
  "transactionType": "BUY",
  "quantity": "1500",
  "productType": "NRML",
  "orderType": "L",
  "triggerPrice": "1180",
  "limitPrice": "1160"
}

r = requests.post('https://tradeapi.samco.in/gttoco/addGtt',
  data=json.dumps(requestBody),
  headers=headers)

print(r.json())

Sample Responses

json
{
  "serverTime": "30/05/24 11:42:25",
  "msgId": "b74e09a8-4925-42cd-bca3-2a96872684e0",
  "status": "Success",
  "statusMessage": "GTT CREATED",
  "gttSummaryId": "140954",
  "orderDetails": {
    "productType": "NRML",
    "orderType": "L",
    "triggerPrice": "1180",
    "marketProtection": "",
    "transactionType": "BUY",
    "triggerId": "177902",
    "symbol": "146465_NFO",
        "symbolName": "WIPRO24JUN585PE",
        "createdAt": "2024-05-30 11:42:25"
    }
}
json
{
    "serverTime": "29/05/24 18:47:38",
    "msgId": "5e1d73de-347a-4174-8dde-70d5f9c1c56b",
    "status": "Success",
    "statusMessage": "GTT CREATED",
    "gttSummaryId": "931720",
    "orderDetails": {
        "productType": "NRML",
        "orderType": "MKT",
        "triggerPrice": "11.7",
        "marketProtection": "3",
        "transactionType": "BUY",
        "triggerId": "1325140",
        "symbol": "14366_NSE",
        "symbolName": "IDEA",
        "createdAt": "2024-05-29 18:47:38"
    }
}
json
{
  "serverTime": "14/05/24 13:49:07",
  "status": "Failure",
  "statusMessage": "No Symbol found for the provided symbol name and exchange."
}

Response Schema

Status Code 200

NameTypeDescription
serverTimestringThe timestamp when the server generated the response.
msgIdstringA unique identifier for the message, used to track the response.
statusstringThe status of the API response. Possible values: 'Success', 'Error', or 'Failure'.
statusMessagestringA message providing additional details about the status.
gttSummaryIdstringUniquely identifies the GTT order, essential for modifying, retrieving status, and deleting.
productTypestringThe product type used in the order.
orderTypestringThe type of order placed.
triggerPricestringThe price at which the GTT order is triggered.
marketProtectionstringAn optional field for market protection, used to limit market exposure.
transactionTypestringIndicates whether the order is a buy or sell transaction.
triggerIdstringA unique identifier for the GTT trigger.
symbolstringThe actual name of the symbol for the scrip.
symbolNamestringThe name of the financial instrument.
createdAtstringThe timestamp when the GTT order was created.