Skip to content

Modify Basket Order

PUT basket/modifyBasketOrder

The modifyBasketOrder API allows you to modify an existing order within a specific basket by targeting the order's unique ID. This API enables you to adjust various parameters of the order, such as quantity, price, or other details, ensuring that the order aligns with updated trading strategies or market conditions. It's designed to provide flexibility and precision in managing your basket orders.

In a modify order, we can replace the old order with the same order ID with a new order.

Parameters

NameTypeRequiredDescription
basketOrderIdstringtrueUnique identifier of the specific order within the basket that you want to modify.
basketIdstringtrueUnique identifier of the basket containing the order.
symbolNamestringfalseThe stock symbol to be traded.
exchangestringfalseThe exchange where the stock is listed.
transactionTypestringfalseIndicates whether the transaction is BUY or SELL.
orderTypestringfalseSpecifies the order type (e.g., L - Limit, SL - Stop Limit).
orderValiditystringfalseSpecifies the order's validity duration.
productTypestringfalseSpecifies the product type (e.g., CNC - Cash and Carry, CO - Cover Order, BO - Bracket Order, NRML, MIS).
quantitystringfalseThe number of shares or units to be traded.
disclosedQuantitystringfalseThe quantity to be disclosed in the market, which can be equal to or less than the order quantity.
pricestringfalseThe execution price for the order. Mandatory for L or SL orders.
priceTypestringfalseApplicable only for BO orders. Valid options: LTP (Last Traded Price) or ATP (Average Traded Price). Default is LTP.
squareOffValuestringfalseThe value used to square off the position automatically. Applicable only for BO orders.
stopLossValuestringfalseThe stop-loss value. Applicable only for BO orders.
valueTypestringfalseThe type of value for Stop Loss and Square Off. Valid options: Absolute or Ticks. Default is Absolute. Applicable only for BO orders.
trailingStopLossstringfalseIncremental value as a percentage of the price change. The trailing stop loss moves with price increases but stays fixed if the price drops. Applicable only for BO orders.
triggerPricestringfalseThe price at which the order will be triggered. Applicable for SL orders.

Sample Code

bash
curl -X PUT 'https://tradeapi.samco.in/basket/modifyBasketOrder' \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'x-session-token: <SESSION_TOKEN>' \
  -d '{"basketId":"6","basketOrderId":"12","orderType":"L","quantity":"100","price":"1500.00","orderValidity":"DAY","productType":"CNC"}'
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 = """
        {
          "basketId": "6",
          "basketOrderId": "12",
          "orderType": "L",
          "quantity": "100",
          "price": "1500.00",
          "orderValidity": "DAY",
          "productType": "CNC"
        }
        """;

    HttpClient client = HttpClient.newHttpClient();

    HttpRequest request = HttpRequest.newBuilder()
        .uri(URI.create("https://tradeapi.samco.in/basket/modifyBasketOrder"))
        .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 = {
    basketId: "6",
    basketOrderId: "12",
    orderType: "L",
    quantity: "100",
    price: "1500.00",
    orderValidity: "DAY",
    productType: "CNC"
  };

  const response = await fetch('https://tradeapi.samco.in/basket/modifyBasketOrder', {
    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 = {
  "basketId": "6",
  "basketOrderId": "12",
  "orderType": "L",
  "quantity": "100",
  "price": "1500.00",
  "orderValidity": "DAY",
  "productType": "CNC"
}

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

print(r.json())

Sample Responses

json
{
    "serverTime": "21/08/24 15:08:43",
    "msgId": "e70296a1-f06e-4976-a00e-e5fca43532b9",
    "status": "Success",
    "statusMessage": "Basket Order Data Updated Successfully"
}
json
{
    "serverTime": "21/08/24 15:30:31",
    "msgId": "7f8bc4f0-8641-40e9-ae7d-abe0b9520a99",
    "status": "Failure",
    "statusMessage": "Invalid basket order id or BasketId "
}

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 request, typically 'Success', 'Error', or 'Failure'.
statusMessagestringA message providing more details about the status.