Skip to content

Delete OCO

DELETE /gttoco/deleteOco

Deleting an OCO (One-Cancels-the-Other) order involves canceling both legs of the order simultaneously. In an OCO order, when one part of the order is executed, the other part is automatically canceled. However, if the investor decides to delete the entire OCO order before either part is executed, they can do so using the delete OCO API.

Steps to Delete 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 delete.

Parameters

NameTypeRequiredDescription
gttSummaryIdnumbertrueEnter the gttSummaryId of the GTT order you want to delete here.

Sample Request Body

json
requestBody={
    "gttSummaryId" : 136045
}

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 DELETE 'https://tradeapi.samco.in/gttoco/deleteOco' \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'x-session-token: <SESSION_TOKEN>' \
  -d '{"gttSummaryId":136045}'
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 = """
        {
          "gttSummaryId": 136045
        }
        """;

    HttpClient client = HttpClient.newHttpClient();

    HttpRequest request = HttpRequest.newBuilder()
        .uri(URI.create("https://tradeapi.samco.in/gttoco/deleteOco"))
        .header("Content-Type", "application/json")
        .header("Accept", "application/json")
        .header("x-session-token", "<SESSION_TOKEN>")
        .method("DELETE", 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 = {
    gttSummaryId: 136045
  };

  const response = await fetch('https://tradeapi.samco.in/gttoco/deleteOco', {
    method: 'DELETE',
    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 = {
  "gttSummaryId": 136045
}

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

print(r.json())

Sample Response

json
{
  "serverTime": "28/02/24 12:49:19",
  "status": "Success",
  "msgId": "a62afb04-84a5-4d3d-ba5b-3299cce4fd77",
  "gttSummaryId": "136045",
  "statusMessage": "GTT OCO order Deleted",
  "orderDetails": {
    "userId": "RM1001"
  }
}

Response Schema

Status Code 200

NameTypeDescription
serverTimestringTime at Server.
msgIdstringThis is a 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.
gttSummaryIdstringgttSummaryId of the order which is deleted.
userIdstringUser ID of the user who deleted the order.