Margin Calculation¶
This API allows you to calculate the margin requirement for an order before placing it. This helps you understand the funds needed and plan your trades accordingly.
| Request Type | Path | Description |
|---|---|---|
| GET | /margin | Calculate margin requirement for an order |
Margin Calculation¶
Calculate the margin requirement for a single order before placing it.
Endpoint
Request Body
| Parameter | Type | Mandatory | Description |
|---|---|---|---|
segment | string | ✅ | The market segment. Enum: "DERIVATIVE", "EQUITY", "COMMODITY" |
exchange | string | ✅ | The exchange. Enum: "NSE", "BSE", "MCX" (MCX only with segment: "COMMODITY") |
securityID | string | ✅ | The unique identifier for the instrument |
txnType | string | ✅ | The transaction type. Enum: "BUY", "SELL" |
quantity | string | ✅ | The quantity of the instrument to trade. |
price | string | ✅ | The price per unit. May be left empty or "0", in which case the live price is used. |
product | string | ✅ | The product type. Enum: "MARGIN", "INTRADAY", "CNC" |
Example Request
Bash
curl --location --request GET 'https://api.indstocks.com/margin' \
--header 'Authorization: YOUR_ACCESS_TOKEN' \
--header 'Content-Type: application/json' \
--data '{
"segment": "DERIVATIVE",
"txnType": "BUY",
"quantity": "75",
"price": "10",
"product": "MARGIN",
"securityID": "40131",
"exchange": "NSE"
}'
Response Payload (Success)
JSON
{
"status": "success",
"data": {
"total_margin": 750,
"span_margin": 0,
"ha": false,
"hedge_benefit": 0,
"exposure_margin": 0,
"available_balance": 0,
"var_margin": 0,
"insufficient_balance": 0,
"delivery_margin": 0,
"brokerage": 0,
"charges": {
"stt": 0,
"exchange_charges": 0,
"stamp_duty": 0,
"sebi_turn_over_charges": 0,
"brokerage": 10,
"gst": 1.8,
"IPFTCharges": 0,
"total_charges": 11.8
}
}
}
Response Fields
| Field | Type | Description |
|---|---|---|
total_margin | number | Total margin required for the order |
span_margin | number | SPAN margin requirement |
ha | boolean | Whether a hedge benefit applies to the order |
hedge_benefit | number | Margin benefit from hedged positions |
exposure_margin | number | Exposure margin requirement |
available_balance | number | Available balance after margin requirement |
var_margin | number | Value at Risk (VAR) margin |
insufficient_balance | number | Shortfall amount if balance is insufficient |
delivery_margin | number | Delivery margin for equity trades |
brokerage | number | Brokerage amount (typically ₹10 per order for API users) |
Charges Breakdown
| Field | Type | Description |
|---|---|---|
stt | number | Securities Transaction Tax |
exchange_charges | number | Exchange transaction charges |
stamp_duty | number | Government stamp duty |
sebi_turn_over_charges | number | SEBI turnover charges |
brokerage | number | Brokerage charges (₹10 per order) |
gst | number | GST on brokerage and charges (18%) |
IPFTCharges | number | Investor Protection Fund Trust charges |
total_charges | number | Sum of all charges |
Response Notes
- All amounts are in INR (Indian Rupees)
- Brokerage is flat ₹10 per order regardless of order size
- GST is calculated at 18% on brokerage and other charges
total_marginrepresents the total funds required to place the order- For derivative orders, SPAN and exposure margins may apply
- For equity delivery orders, delivery margin may be applicable
Commodity (MCX) Margin¶
Send segment: "COMMODITY" with exchange: "MCX" and product "MARGIN" or "INTRADAY".
Example Request
Bash
curl --location --request GET 'https://api.indstocks.com/margin' \
--header 'Authorization: YOUR_ACCESS_TOKEN' \
--header 'Content-Type: application/json' \
--data '{
"segment": "COMMODITY",
"exchange": "MCX",
"txnType": "BUY",
"quantity": "100",
"price": "8632",
"product": "MARGIN",
"securityID": "565899"
}'
Response Payload (Success)
JSON
{
"status": "success",
"data": {
"total_margin": 117480.5,
"span_margin": 86320,
"ha": false,
"hedge_benefit": 0,
"exposure_margin": 31160.5,
"available_balance": 0,
"var_margin": 0,
"insufficient_balance": 0,
"delivery_margin": 0,
"brokerage": 0,
"charges": null
}
}
Commodity margin rules
- The response fills
total_margin,span_margin,exposure_marginanddelivery_margin. The other amounts are0, andchargesisnull— commodity charges are not estimated here. quantitymust be a positive whole number in units —quantity must be a positive integer.price, when sent, must be a non-negative number. Leave it empty or send"0"to use the live price.exchangemust beMCXandproductmust beMARGINorINTRADAY— for exampleProduct is missing or invalid; allowed values: MARGIN, INTRADAY.- These are
400errors, returned before any margin is calculated. If the margin service rejects a valid request, the response is512withUnable to fetch margin details.
See Also¶
- Orders — place the order once margin is confirmed
- Get Funds — check available balance against the calculated margin
- Error Bucket — RMS margin-related rejection messages