SPAN Margin Calculator
This API allows you to calculate the combined SPAN and exposure margin for futures and options, including margin benefits from hedges and individual instrument margin details.
USE CASE
Compare hedged and unhedged strategies and understand the margin required for the combined basket.
Note
- A maximum of 20 symbols is allowed per request.
- Each entry in the
dataarray counts towards this limit. - Zero SPAN margin for bought options does not mean zero premium cost.
Details
- Pass the instrument details inside a
dataarray. - Margin fields are returned inside
data. Individual instrument details are returned separately inindividual_info. - The example buys OTM hedges before selling ATM options.
- The result is based only on the instruments you send. It does not depend on your existing positions, the order of the orders, or the product type. To include your positions and the order sequence, use the Multi-order Margin Calculator.
- Rate limits differ between the Standard and Prime plans. See Plans & rate limits.
Request Attributes
| Attribute | Data Type | Description |
|---|---|---|
symbol | string | Futures or options symbol in FYERS symbology format. Equity symbols are not supported. |
qty | int | Quantity. For NSE and BSE derivatives, in units, as a multiple of the lot size. For MCX, the number of lots. |
side | int | 1 = Buy; -1 = Sell. |
type | int | The order type does not change the calculated margin. |
productType | string | Product type, such as INTRADAY or MARGIN. It does not change the calculated margin. |
limitPrice | float | Limit price, where applicable. Use 0.0 for market orders. Can be omitted. It does not change the calculated margin. |
stopLoss | float | Stop-loss value, where applicable. Use 0.0 otherwise. Can be omitted. |
Response Attributes
| Attribute | Data Type | Description |
|---|---|---|
s | string | ok / error. |
code | int | API response code. 200 on success; -50, -310, -209 or -17 for errors. |
message | string | Response or error message. Empty on success. |
latency | string | Reserved. Returned empty. |
data.span | float | Combined SPAN risk margin for the basket. |
data.expo | float | Combined exposure margin for the basket. |
data.total | float | Combined margin requirement: SPAN plus exposure margin. |
data.benefit | float | Margin saving from combining the legs. It equals the sum of the individual totals minus total, and is already reflected in total; do not subtract it again. |
individual_info | object | Individual margin details, keyed by FYERS instrument token. |
individual_info[token].ltp_info | float | Instrument’s last traded price reported by the calculator. |
individual_info[token].span | float | Individual SPAN margin. |
individual_info[token].expo | float | Individual exposure margin. |
individual_info[token].total | float | Individual total margin. |
Errors
| Code | Description |
|---|---|
-50 | Invalid input. |
-310 | Invalid symbol, or more than 20 symbols. |
-209 | Token missing. |
-17 | Authentication failed. |
Last updated on