Skip to Content
API ReferenceMargin CalculatorSPAN Margin Calculator

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 data array counts towards this limit.
  • Zero SPAN margin for bought options does not mean zero premium cost.

Details

  • Pass the instrument details inside a data array.
  • Margin fields are returned inside data. Individual instrument details are returned separately in individual_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

AttributeData TypeDescription
symbolstringFutures or options symbol in FYERS symbology format. Equity symbols are not supported.
qtyintQuantity. For NSE and BSE derivatives, in units, as a multiple of the lot size. For MCX, the number of lots.
sideint1 = Buy; -1 = Sell.
typeint
  • 1 = Limit
  • 2 = Market (MPP: Market Price Protection )
  • 3 = Stop-market (SL-M, MPP: Market Price Protection )
  • 4 = Stop-limit (SL-L)
The order type does not change the calculated margin.
productTypestringProduct type, such as INTRADAY or MARGIN. It does not change the calculated margin.
limitPricefloatLimit price, where applicable. Use 0.0 for market orders. Can be omitted. It does not change the calculated margin.
stopLossfloatStop-loss value, where applicable. Use 0.0 otherwise. Can be omitted.

Response Attributes

AttributeData TypeDescription
sstringok / error.
codeintAPI response code. 200 on success; -50, -310, -209 or -17 for errors.
messagestringResponse or error message. Empty on success.
latencystringReserved. Returned empty.
data.spanfloatCombined SPAN risk margin for the basket.
data.expofloatCombined exposure margin for the basket.
data.totalfloatCombined margin requirement: SPAN plus exposure margin.
data.benefitfloatMargin 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_infoobjectIndividual margin details, keyed by FYERS instrument token.
individual_info[token].ltp_infofloatInstrument’s last traded price reported by the calculator.
individual_info[token].spanfloatIndividual SPAN margin.
individual_info[token].expofloatIndividual exposure margin.
individual_info[token].totalfloatIndividual total margin.

Errors

CodeDescription
-50Invalid input.
-310Invalid symbol, or more than 20 symbols.
-209Token missing.
-17Authentication failed.
Last updated on