Position Square Off
POST /position/squareOff
SqareOff existing position. Mostly used in day trading, in which user buy or sell a particular quantity of a stock and later in the day reverse the transaction to earn a profit.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
positionSquareOffRequestList | Array | true | List of position square-off requests |
exchange | String | true | Exchange code (e.g., NSE, BSE) |
symbolName | String | true | Symbol name (e.g., TCS, INFY) |
productType | String | true | Product type (e.g., MIS) |
netQuantity | String | true | Net quantity of the position |
transactionType | String | true | Transaction type (e.g., BUY, SELL) |
Sample Request Body
json
requestBody={
"positionSquareOffRequestList": [
{
"exchange": "NSE",
"symbolName": "TCS",
"productType": "MIS",
"netQuantity": "250",
"transactionType": "BUY"
},
{
"exchange": "BSE",
"symbolName": "INFY",
"productType": "MIS",
"netQuantity": "25",
"transactionType": "SELL"
}
]
}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/position/squareOff' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'x-session-token: <SESSION_TOKEN>' \
-d '{"positionSquareOffRequestList":[{"exchange":"NSE","symbolName":"TCS","productType":"MIS","netQuantity":"250","transactionType":"BUY"},{"exchange":"BSE","symbolName":"INFY","productType":"MIS","netQuantity":"25","transactionType":"SELL"}]}'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 = """
{
"positionSquareOffRequestList": [
{
"exchange": "NSE",
"symbolName": "TCS",
"productType": "MIS",
"netQuantity": "250",
"transactionType": "BUY"
},
{
"exchange": "BSE",
"symbolName": "INFY",
"productType": "MIS",
"netQuantity": "25",
"transactionType": "SELL"
}
]
}
""";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://tradeapi.samco.in/position/squareOff"))
.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 = {
positionSquareOffRequestList: [
{
exchange: "NSE",
symbolName: "TCS",
productType: "MIS",
netQuantity: "250",
transactionType: "BUY"
},
{
exchange: "BSE",
symbolName: "INFY",
productType: "MIS",
netQuantity: "25",
transactionType: "SELL"
}
]
};
const response = await fetch('https://tradeapi.samco.in/position/squareOff', {
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 = {
"positionSquareOffRequestList": [
{
"exchange": "NSE",
"symbolName": "TCS",
"productType": "MIS",
"netQuantity": "250",
"transactionType": "BUY"
},
{
"exchange": "BSE",
"symbolName": "INFY",
"productType": "MIS",
"netQuantity": "25",
"transactionType": "SELL"
}
]
}
r = requests.post('https://tradeapi.samco.in/position/squareOff',
data=json.dumps(requestBody),
headers=headers)
print(r.json())Sample Responses
json
{
"serverTime": "12/12/19 16:20:11",
"msgId": "786cdd94-2fc9-4c38-8f14-672ec64dd032",
"positionSquareOffResponseList": [
{
"serverTime": "12/12/19 16:20:11",
"msgId": "786cdd94-2fc9-4c38-8f14-672ec64dd032",
"status": "Success",
"statusMessage": "Request successful"
}
]
}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. |
positionSquareOffResponseList | Array | List of the PositionSquareOff end of the day. |
status | String | Response status. Can be Success or Failure. |
statusMessage | String | Status Message. |