---
title: "margin calculator"
method: POST
path: "/margincalculator"
tags: ["Funds & Margin"]
---

# margin calculator

`POST /margincalculator`

Margin Calculation API lets you calculate span, exposure, var, brokerage, leverage, available  margin values for any type of order and instrument.

## Headers

- `access-token` string, required

## Request body

- KnowYourMarginReq
  - `dhanClientId` string — User specific identification generated by Dhan
  - `exchangeSegment` 'NSE_EQ' | 'NSE_FNO' | 'BSE_EQ' | 'BSE_FNO' | 'MCX_COMM', required — | **Enums** | **Exchange** | **Segment** | |--------------|--------------|-------------------| | NSE_EQ | NSE | Equity Cash | | NSE_FNO | NSE | Futures & Options | | BSE_EQ | BSE | Equity Cash | | BSE_FNO | BSE | Futures & Options | | MCX_COMM | MCX | Commodity |
  - `transactionType` 'BUY' | 'SELL', required — Signifies the type of transaction whether it's BUY or SELL
  - `quantity` integer — Number of shares for the order
  - `productType` 'CNC' | 'INTRADAY' | 'MARGIN' | 'MTF' | 'CO' | 'BO' — | **Enum Values** | **Description** | |-----------------|------------------------------------------------| | CNC | Cash & Carry for equity deliveries | | INTRADAY | Intraday for Equity, Futures & Options | | MARGIN | Carry Forward in Futures & Options | | CO | Cover Order; entry and stop loss | | BO | Bracket Order; entry, stop loss & target price | **CO & BO product types will be valid only for Intraday**
  - `securityId` string — Exchange standard identification for each scrip
  - `price` number, float — Price at which the order is requested to execute
  - `triggerPrice` number, float — Price at which the order is requested to trigger

## Response `200`

Successful operation

- KnowYourMarginResponse
  - `totalMargin` number, float — Total available margin to trade
  - `spanMargin` number, float — Available span margin
  - `exposureMargin` number, float — Available exposure margin
  - `availableBalance` number, float — Available balance to trade
  - `variableMargin` number, float — Variable margin
  - `insufficientBalance` number, float — Insufficient balance
  - `brokerage` number, float — Applicable brokerage
  - `leverage` string — Applicable leverage

---

[API](https://skmtc.dev/dhan/apis/dhanhq-api.md) · [All operations](https://skmtc.dev/dhan/apis/dhanhq-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/dhan/dhanhq-api/revisions/2d368b9ed32d/schema)
