Skip to content

Modify OCO

PUT /gttoco/modifyOco

Modifying a GTT OCO (Good Till Triggered, One-Cancels-the-Other) order involves adjusting the parameters of an existing GTT OCO order. This can include changing the trigger prices, adjusting the quantity of the order, or modifying the order types.

When modifying a GTT OCO order, investors can make changes to both legs of the OCO order, ensuring that the exit strategies remain aligned with their trading objectives and market conditions. For example, if market conditions change and the investor wants to adjust their profit target or stop-loss levels, they can modify the trigger prices accordingly.

Steps to modify a GTT OCO order :

  1. Retrieve all active GTT orders using the List GTT OCO API. In the 'List GTT OCO ' API response, we will get both active GTT and GTT OCO orders. To identify an OCO order, check if the 'triggers' key in the API response contains both 'stopLoss' and 'target' keys. If it does, then it is an OCO order.
  2. Note down the GTT summary ID of the order you wish to modify.Then, based on the parameters provided below, you can modify your order.

Parameters

NameTypeRequiredDescription
exchangestringtrueThe exchange remains the same as when creating the GTT OCO. It cannot be modified.
symbolNamestringtrueThe symbol name remains the same as when creating the GTT OCO. It cannot be modified.
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 (Cash and Carry) or NRML (Normal).
orderTypestringtrueType of order placed. Can be MKT (Market Order) or L (Limit Order).
targetTriggerPricestringtrueThe price at which the target order will enter the market.
targetLimitPricestringtrueRequired for limit orders. The price at which the target order will be executed on the exchange.
stoplossTriggerPricestringtrueThe price at which the stop-loss order will enter the market.
stoplossLimitPricestringtrueRequired for limit orders. The price at which the stop-loss order will be executed on the exchange.
marketProtectionstringtrueRequired for market orders. Default is set to 3% to protect the order from potential market losses.
gttSummaryIdnumbertrueEnter the gttSummaryId of the GTT OCO order you want to modify here.

Sample Request Body

json
requestBody={
  "exchange": "NSE",
  "symbolName": "IDEA",
  "transactionType": "SELL",
  "quantity": "25",
  "productType": "CNC",
  "orderType": "L",
  "targetTriggerPrice": "13.5",
  "targetLimitPrice": "13.5",
  "stoplossTriggerPrice": "10.5",
  "stoplossLimitPrice": "10.5",
  "marketProtection": "",
  "gttSummaryId" : 670745
}

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 PUT 'https://tradeapi.samco.in/gttoco/modifyOco' \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'x-session-token: <SESSION_TOKEN>' \
  -d '{"exchange":"NSE","symbolName":"IDEA","transactionType":"SELL","quantity":"25","productType":"CNC","orderType":"L","targetTriggerPrice":"13.5","targetLimitPrice":"13.5","stoplossTriggerPrice":"10.5","stoplossLimitPrice":"10.5","marketProtection":"","gttSummaryId":670745}'
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": "NSE",
          "symbolName": "IDEA",
          "transactionType": "SELL",
          "quantity": "25",
          "productType": "CNC",
          "orderType": "L",
          "targetTriggerPrice": "13.5",
          "targetLimitPrice": "13.5",
          "stoplossTriggerPrice": "10.5",
          "stoplossLimitPrice": "10.5",
          "marketProtection": "",
          "gttSummaryId": 670745
        }
        """;

    HttpClient client = HttpClient.newHttpClient();

    HttpRequest request = HttpRequest.newBuilder()
        .uri(URI.create("https://tradeapi.samco.in/gttoco/modifyOco"))
        .header("Content-Type", "application/json")
        .header("Accept", "application/json")
        .header("x-session-token", "<SESSION_TOKEN>")
        .PUT(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: "NSE",
    symbolName: "IDEA",
    transactionType: "SELL",
    quantity: "25",
    productType: "CNC",
    orderType: "L",
    targetTriggerPrice: "13.5",
    targetLimitPrice: "13.5",
    stoplossTriggerPrice: "10.5",
    stoplossLimitPrice: "10.5",
    marketProtection: "",
    gttSummaryId: 670745
  };

  const response = await fetch('https://tradeapi.samco.in/gttoco/modifyOco', {
    method: 'PUT',
    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": "NSE",
  "symbolName": "IDEA",
  "transactionType": "SELL",
  "quantity": "25",
  "productType": "CNC",
  "orderType": "L",
  "targetTriggerPrice": "13.5",
  "targetLimitPrice": "13.5",
  "stoplossTriggerPrice": "10.5",
  "stoplossLimitPrice": "10.5",
  "marketProtection": "",
  "gttSummaryId": 670745
}

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

print(r.json())

Sample Response

json
{
  "serverTime": "04/04/24 13:53:23",
  "msgId": "432b12e6-6acc-4b38-98b3-3940e09d0c26",
  "status": "Success",
  "statusMessage": "GTT MODIFIED",
  "gttSummaryId": "671170",
  "orderDetails": {
    "transactionType": "SELL",
    "orderType": "L",
    "symbol": "14366_NSE",
    "symbolName": "IDEA",
    "productType": "CNC",
    "target": {
      "limitPrice": "13.5",
      "triggerId": "932815",
      "triggerPrice": "13.5",
      "type": "TARGET",
      "quantity": "25",
      "marketProtection": ""
    },
    "stopLoss": {
      "limitPrice": "10.5",
      "triggerId": "932820",
      "triggerPrice": "10.5",
      "type": "STOPLOSS",
      "quantity": "25",
      "marketProtection": ""
    }
  }
}

Response Schema

Status Code 200

NameTypeDescription
serverTimestringTime at Server.
msgIdstringA unique identifier for every request into the system. Please quote this identifier to the support team if you face issues with the API request.
statusstringThe status of the API response. It can be either 'Success' or 'Failure'.
statusMessagestringA message describing the result of the API call.
gttSummaryIdstringAfter the order is modified, a new gttSummaryId is generated. For any further operation, this gttSummaryId will be valid for this order and the old gttSummaryId becomes invalid.
transactionTypestringDescribes whether the transaction involves buying or selling.
orderTypestringThe type of order.
symbolstringThe actual name of the symbol for the scrip.
symbolNamestringThe name of the symbol representing the scrip.
productTypestringThe product type of the order.
targetobjectAn object containing details about the target order.
stopLossobjectAn object containing details about the stop loss order.