Funds & Margin
Users can get details about the fund requirements or available funds (with margin requirements) in their Trading Account.
| POST | /margincalculator | Margin requirement for any order |
| GET | /fundlimit | Retrieve Available Fund Limits |
| POST | /margincalculator/multi | Calculate Margin for Multiple Orders |
Margin Calculator
Fetch span, exposure, var, brokerage, leverage, available margin values for any type of order and instrument that you want to place.
curl --request POST \
--url https://api.dhan.co/v2/margincalculator \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'access-token: ' \
--data '{Request JSON}'
Request Structure
{
"dhanClientId": "1000000132",
"exchangeSegment": "NSE_EQ",
"transactionType": "BUY",
"quantity": 5,
"productType": "CNC",
"securityId": "1333",
"price": 1428,
"triggerPrice": 1427,
}
Parameters
| Field | Type | Description |
| dhanClientId required |
string | User specific identification generated by Dhan |
| exchangeSegment required |
enum string | Exchange & SegmentNSE_EQ NSE_FNO
BSE_EQ BSE_FNO
MCX_COMM |
| transactionType required |
enum string | The trading side of transaction BUY SELL |
| quantity required |
int | Number of shares for the order |
| productType required |
enum string | Product typeCNC INTRADAY MARGIN MTF CO BO |
| securityId required |
string | Exchange standard id for each scrip. Refer here |
| price required |
float | Price at which order is placed |
| triggerPrice conditionally required |
float | Price at which the order is triggered, in case of SL-M & SL-L |
Response Structure
{
"totalMargin": 2800.00,
"spanMargin": 1200.00,
"exposureMargin": 1003.00,
"availableBalance": 10500.00,
"variableMargin": 1000.00,
"insufficientBalance": 0.00,
"brokerage": 20.00,
"leverage": "4.00"
}
Parameters
| Field | Type | Description |
| totalMargin | float | Total Margin required for placing the order successfully |
| spanMargin | float | SPAN margin required |
| exposureMargin | float | Exposure margin required |
| availableBalance | float | Available amount in trading account |
| variableMargin | float | VAR or Variable margin required |
| insufficientBalance | float | Insufficient amount in trading account (Available Balance - Total Margin) |
| brokerage | float | Brokerage charges for executing order |
| leverage | string | Margin leverage provided for the order as per product type |
Multi Order Margin Calculator
The Multi Order Margin Calculator API allows users to calculate margin requirements for multiple scripts in a single request, including span, exposure, equity, F&O, and commodity margins.
Note: Margin values returned are indicative and valid only for the current trading session.
Curl Request
curl --request POST \
--url https://api.dhan.co/v2/margincalculator/multi \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'access-token: ' \
--data '{
"includePosition": true,
"includeOrder": true,
"dhanClientId": "string",
"scripList": [
{
"exchangeSegment": "NSE_EQ",
"transactionType": "string",
"quantity": 0,
"productType": "CNC",
"securityId": "string",
"price": 0,
"triggerPrice": 0
}
]
}'
Request Structure
{
"includePosition": true,
"includeOrders": true,
"scripts": [
{
"exchangeSegment": "NSE_EQ",
"transactionType": "BUY",
"quantity": 100,
"productType": "CNC",
"securityId": "12345",
"price": 250.50
}
]
}
Parameters
| Parameter | Data Type | Description |
|---|---|---|
| includePosition | boolean | Include existing positions in margin calculation |
| includeOrders | boolean | Include open orders in margin calculation |
| scripts | array | List of scripts to calculate margin for |
| exchangeSegment | string | Exchange & segment (e.g. NSE_EQ, NSE_FNO) |
| transactionType | string | BUY or SELL |
| quantity | integer | Order quantity |
| productType | string | CNC, INTRADAY, MARGIN, MTF |
| securityId | string | Exchange security identifier |
| price | float | Order price |
| triggerPrice | number | Trigger price (if applicable) |
Response Structure
{
"total_margin": "150000.00",
"span_margin": "50000.00",
"exposure_margin": "30000.00",
"equity_margin": "70000.00",
"fo_margin": "0.00",
"commodity_margin": "0.00",
"currency": "INR",
"hedge_benefit": ""
}
Fund Limit
Get all information of your trading account like balance, margin utilised, collateral, etc.
curl --request GET \
--url https://api.dhan.co/v2/fundlimit \
--header 'Content-Type: application/json' \
--header 'access-token: JWT'
Request Structure
No Body
Response Structure
{
"dhanClientId":"1000000009",
"availabelBalance": 98440.0,
"sodLimit": 113642,
"collateralAmount": 0.0,
"receiveableAmount": 0.0,
"utilizedAmount": 15202.0,
"blockedPayoutAmount": 0.0,
"withdrawableBalance": 98310.0
}
Parameters
| Field | Type | Description |
| dhanClientId | string | User specific identification generated by Dhan |
| availabelBalance | float | Available amount to trade |
| sodLimit | float | Start of the day balance in account |
| collateralAmount | float | Amount received against collateral |
| receiveableAmount | float | Amount available against selling deliveries |
| utilizedAmount | float | Amount utilised in the day |
| blockedPayoutAmount | float | Amount blocked against payout request |
| withdrawableBalance | float | Amount available to withdraw in bank account |
Note: For description of enum values, refer Annexure