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
| Name | Type | Required | Description |
|---|---|---|---|
basketOrderId | string | true | Unique identifier of the specific order within the basket that you want to modify. |
basketId | string | true | Unique identifier of the basket containing the order. |
symbolName | string | false | The stock symbol to be traded. |
exchange | string | false | The exchange where the stock is listed. |
transactionType | string | false | Indicates whether the transaction is BUY or SELL. |
orderType | string | false | Specifies the order type (e.g., L - Limit, SL - Stop Limit). |
orderValidity | string | false | Specifies the order's validity duration. |
productType | string | false | Specifies the product type (e.g., CNC - Cash and Carry, CO - Cover Order, BO - Bracket Order, NRML, MIS). |
quantity | string | false | The number of shares or units to be traded. |
disclosedQuantity | string | false | The quantity to be disclosed in the market, which can be equal to or less than the order quantity. |
price | string | false | The execution price for the order. Mandatory for L or SL orders. |
priceType | string | false | Applicable only for BO orders. Valid options: LTP (Last Traded Price) or ATP (Average Traded Price). Default is LTP. |
squareOffValue | string | false | The value used to square off the position automatically. Applicable only for BO orders. |
stopLossValue | string | false | The stop-loss value. Applicable only for BO orders. |
valueType | string | false | The type of value for Stop Loss and Square Off. Valid options: Absolute or Ticks. Default is Absolute. Applicable only for BO orders. |
trailingStopLoss | string | false | Incremental 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. |
triggerPrice | string | false | The 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
| Name | Type | Description |
|---|---|---|
serverTime | string | Time at Server. |
msgId | string | This 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. |
status | string | The status of the API request, typically 'Success', 'Error', or 'Failure'. |
statusMessage | string | A message providing more details about the status. |