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
| Name | Type | Required | Description |
|---|---|---|---|
exchange | string | true | The 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. |
symbolName | string | true | Symbol name of the scrip. For Equity, enter the SymbolName of the scrip. For Derivatives, enter the TradingSymbol of the scrip. |
transactionType | string | true | Determines whether the order is a buy or sell transaction. |
quantity | string | true | Defines the number of units or shares of the asset to be bought or sold. |
productType | string | true | Product type of the order. Can be CNC, NRML. The valid product type for F&O (Futures and Options) is NRML. |
orderType | string | true | Type of order placed. Can be MKT (Market Order) or L (Limit Order). |
triggerPrice | string | true | Represents the market-entry price level for the placed order. |
limitPrice | string | true | Required for L (Limit) orders. This is the price at which the order is executed in the market. |
marketProtection | string | true | Required 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
| Name | Type | Description |
|---|---|---|
serverTime | string | The timestamp when the server generated the response. |
msgId | string | A unique identifier for the message, used to track the response. |
status | string | The status of the API response. Possible values: 'Success', 'Error', or 'Failure'. |
statusMessage | string | A message providing additional details about the status. |
gttSummaryId | string | Uniquely identifies the GTT order, essential for modifying, retrieving status, and deleting. |
productType | string | The product type used in the order. |
orderType | string | The type of order placed. |
triggerPrice | string | The price at which the GTT order is triggered. |
marketProtection | string | An optional field for market protection, used to limit market exposure. |
transactionType | string | Indicates whether the order is a buy or sell transaction. |
triggerId | string | A unique identifier for the GTT trigger. |
symbol | string | The actual name of the symbol for the scrip. |
symbolName | string | The name of the financial instrument. |
createdAt | string | The timestamp when the GTT order was created. |