Margin API
Calculate margin requirements and trading charges for individual orders and basket orders, taking into account existing positions and open orders.
Overview
The Margin API enables precise calculation of capital requirements before order placement, helping traders assess available margin and understand the cost structure of their trades. The API supports both individual order margin calculations with detailed charge breakdowns and basket-level margin calculations for multi-instrument strategies.
Endpoint Reference
Calculate Order Margin
Calculate margin requirements and detailed charges for a single order, considering existing positions and open orders.
Endpoint Details
Method: POST
URL: /margin/order
Authentication: Required (appID + token)
Request Headers
| Header | Type | Required | Description |
|---|---|---|---|
appID |
string | ✓ | Your application identifier |
token |
string | ✓ | User authentication token |
Content-Type |
string | ✓ | Must be application/json |
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
exchange |
string | ✓ | Exchange identifier (NSE, BSE, NFO, etc.) |
token |
string | ✓ | Unique instrument token |
quantity |
string | ✓ | Order quantity |
product |
string | ✓ | Product type (M=Margin, C=Cash, etc.) |
price |
string | ✓ | Order price |
transactionType |
string | ✓ | Transaction type (B=Buy, S=Sell) |
order |
string | ✓ | Order type (LMT=Limit, MKT=Market, etc.) |
Request Example
curl --location 'https://edge.arrow.trade/margin/order' \
--header 'appID: <YOUR_APP_ID>' \
--header 'token: <YOUR_TOKEN>' \
--header 'Content-Type: application/json' \
--data '{
"exchange": "NSE",
"symbol": "SBIN-EQ"
"quantity": "100",
"product": "C",
"price": "800",
"transactionType": "B",
"order": "LMT"
}'
const response = await fetch('https://edge.arrow.trade/margin/order', {
method: 'POST',
headers: {
'appID': '<YOUR_APP_ID>',
'token': '<YOUR_TOKEN>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
exchange: 'NSE',
symbol: 'SBIN-EQ'
quantity: '100',
product: 'C',
price: '800',
transactionType: 'B',
order: 'LMT'
})
});
const margin = await response.json();
import requests
headers = {
'appID': '<YOUR_APP_ID>',
'token': '<YOUR_TOKEN>',
'Content-Type': 'application/json'
}
payload = {
'exchange': 'NSE',
'symbol': 'SBIN-EQ',
'quantity': '100',
'product': 'C',
'price': '800',
'transactionType': 'B',
'order': 'LMT'
}
response = requests.post(
'https://edge.arrow.trade/margin/order',
headers=headers,
json=payload
)
margin = response.json()
Success Response
{
"data": {
"requiredMargin": 80000,
"minimumCashRequired": 80000,
"marginUsedAfterTrade": 0,
"charge": {
"brokerage": 0,
"exchangeTxnFee": 2.376,
"gst": {
"cgst": 0,
"igst": 0.45648000000000005,
"sgst": 0,
"total": 0.45648000000000005
},
"ipft": 0.08,
"sebiCharges": 0.08,
"stampDuty": 12,
"total": 94.99248,
"transactionTax": 80
}
},
"status": "success"
}
Response Fields
Root Object
| Field | Type | Description |
|---|---|---|
data |
object | Margin calculation data |
status |
string | Response status indicator |
Data Object
| Field | Type | Description |
|---|---|---|
cash |
string | Available cash balance |
charge |
object | Detailed charge breakdown |
margin |
string | Total margin required for the order |
marginUsed |
string | Margin that will be utilized after order execution |
Charge Object
| Field | Type | Description |
|---|---|---|
brokerage |
number | Brokerage charges |
sebiCharges |
number | SEBI regulatory charges |
exchangeTxnFee |
number | Exchange transaction fees |
stampDuty |
number | Government stamp duty |
ipft |
number | IPFT charges |
transactionTax |
number | Transaction tax (STT/CTT) |
gst |
object | GST breakdown |
total |
number | Total charges amount |
GST Object
| Field | Type | Description |
|---|---|---|
cgst |
number | Central GST component |
sgst |
number | State GST component |
igst |
number | Integrated GST component |
total |
number | Total GST amount |
Calculate Basket Margin
Calculate consolidated margin requirements for multiple orders in a basket, considering portfolio-level risk optimization.
Endpoint Details
Method: POST
URL: /margin/basket
Authentication: Required (appID + token)
Basket vs Order Margin
The basket margin API uses a different RMS calculation methodology that accounts for portfolio-level risk offsetting. For single instruments, margin requirements may differ slightly from the Order Margin API. We recommend using the Order Margin API for individual order calculations to get detailed charge breakdowns.
Request Headers
| Header | Type | Required | Description |
|---|---|---|---|
appID |
string | ✓ | Your application identifier |
token |
string | ✓ | User authentication token |
Content-Type |
string | ✓ | Must be application/json |
Request Body
The request body should be a JSON array of order objects, each containing:
| Field | Type | Required | Description |
|---|---|---|---|
exchange |
string | ✓ | Exchange identifier (NSE, BSE, NFO, etc.) |
token |
string | ✓ | Unique instrument token |
quantity |
string | ✓ | Order quantity |
price |
string | ✓ | Order price |
triggerPrice |
string | ✓ | Trigger price (0 for non-triggered orders) |
product |
string | ✓ | Product type (M=Margin, C=Cash, etc.) |
transactionType |
string | ✓ | Transaction type (B=Buy, S=Sell) |
order |
string | ✓ | Order type (LMT=Limit, MKT=Market, etc.) |
Request Example
curl --location 'https://edge.arrow.trade/margin/basket' \
--header 'appID: <YOUR_APP_ID>' \
--header 'token: <YOUR_TOKEN>' \
--header 'Content-Type: application/json' \
--data '[
{
"exchange": "NFO",
"token": "51641",
"quantity": "900",
"price": "133.5",
"triggerPrice": "0",
"product": "M",
"transactionType": "B",
"order": "LMT"
},
{
"exchange": "NFO",
"token": "46283",
"quantity": "900",
"price": "132",
"triggerPrice": "0",
"product": "M",
"transactionType": "S",
"order": "LMT"
}
]'
const orders = [
{
exchange: 'NFO',
token: '51641',
quantity: '900',
price: '133.5',
triggerPrice: '0',
product: 'M',
transactionType: 'B',
order: 'LMT'
},
{
exchange: 'NFO',
token: '46283',
quantity: '900',
price: '132',
triggerPrice: '0',
product: 'M',
transactionType: 'S',
order: 'LMT'
}
];
const response = await fetch('https://edge.arrow.trade/margin/basket', {
method: 'POST',
headers: {
'appID': '<YOUR_APP_ID>',
'token': '<YOUR_TOKEN>',
'Content-Type': 'application/json'
},
body: JSON.stringify(orders)
});
const basketMargin = await response.json();
import requests
headers = {
'appID': '<YOUR_APP_ID>',
'token': '<YOUR_TOKEN>',
'Content-Type': 'application/json'
}
orders = [
{
'exchange': 'NFO',
'token': '51641',
'quantity': '900',
'price': '133.5',
'triggerPrice': '0',
'product': 'M',
'transactionType': 'B',
'order': 'LMT'
},
{
'exchange': 'NFO',
'token': '46283',
'quantity': '900',
'price': '132',
'triggerPrice': '0',
'product': 'M',
'transactionType': 'S',
'order': 'LMT'
}
]
response = requests.post(
'https://edge.arrow.trade/margin/basket',
headers=headers,
json=orders
)
basket_margin = response.json()
Success Response
Response Fields
Root Object
| Field | Type | Description |
|---|---|---|
data |
object | Basket margin calculation data |
status |
string | Response status indicator |
Data Object
| Field | Type | Description |
|---|---|---|
marginUsed |
string | Current margin utilized in the portfolio |
marginUsedAfterTrade |
string | Projected margin utilization after basket execution |
Sample Margin Calculations
Order Margin Example
Based on the example response for a short futures position:
Futures Short Order
Instrument: NFO Token 72734
Quantity: 25 lots
Price: ₹905
Transaction: Sell (Short)
Margin Required: ₹3,125.00
Total Charges: ₹25.52
Available Cash: ₹276,006.43
Charge Breakdown
| Component | Amount (₹) |
|---|---|
| Brokerage | 20.00 |
| SEBI Charges | 0.003 |
| Exchange Fee | 1.55 |
| Stamp Duty | 0.09 |
| IPFT | 0.02 |
| GST (IGST) | 3.88 |
| Total | 25.52 |
Basket Margin Example
For a hedged futures strategy with two legs:
Futures Spread Strategy
Leg 1: Buy 900 @ ₹133.5 (Token 51641)
Leg 2: Sell 900 @ ₹132 (Token 46283)
Current Margin Used: ₹343,086.95
Margin After Trade: ₹224,261.95
Margin Benefit: ₹118,825.00
Portfolio Risk Offsetting
The basket margin calculation applies portfolio-level risk offsetting, resulting in lower margin requirements for hedged positions compared to calculating each leg separately.
Key Features
Comprehensive Charge Breakdown
The Order Margin API provides complete visibility into all charges associated with a trade, including brokerage, regulatory fees, taxes, and GST components.
Real-time Margin Calculation
Margin calculations consider existing positions and open orders, providing accurate available margin information for order placement decisions.
Portfolio-Level Risk Assessment
The Basket Margin API evaluates multiple orders holistically, identifying risk offsets between positions to optimize margin utilization.
Error Handling
The API follows standard HTTP status codes and returns structured error responses:
Common Issues
- 400 Bad Request: Invalid request parameters or missing required fields
- 401 Unauthorized: Invalid or expired token
- 403 Forbidden: Insufficient permissions
- 429 Too Many Requests: Rate limit exceeded
- 500 Internal Server Error: Server-side processing error
Rate Limits
| Tier | Requests per minute | Burst limit |
|---|---|---|
| Basic | 60 | 10 |
| Premium | 300 | 50 |
| Enterprise | 1000 | 100 |
Integration Notes
Best Practices
- Use Order Margin API for single orders to get detailed charge breakdowns
- Use Basket Margin API for multi-leg strategies to benefit from portfolio-level margin optimization
- Always validate margin availability before order placement
- Cache margin calculations appropriately to minimize API calls
- Implement proper error handling and retry logic
- Consider margin requirements when designing trading strategies
Margin vs Charges
The margin field represents the capital blocked for the position, while charge.total represents the transaction costs. Both are deducted from available cash upon order execution.
Product Types
Different product types (M=Margin, C=Cash) have different margin requirements and leverage. Ensure you understand the implications before trading.