Do explain with a futures spread position and a future and option hedged position.
Hello,
A few points to remember before we get started:
- SPAN stands for Standardised Portfolio Analysis of Risk. SPAN is calculated on your entire portfolio of positions.
- While entering a position, you’ll require to have the entire margin for this position. The system will not be aware of what positions you already have.
- Once the position is taken, SPAN is calculated on your portfolio of positions and if this position results in a SPAN benefit and/or spread benefit in your portfolio, then this benefit amount is released back into your trading account.
- You receive a spread benefit as well as span benefit when you take a Futures spread position.
- You only receive a span benefit when you take a future and option hedged position.
Let’s take 2 examples, one for futures spread and another for a future and options hedge.
Example 1. Futures spread position - spread and margin benefit
You require a margin of about 57k (36k span margin and 21k exposure margin) to buy/sell one lot of Nifty futures as shown in the image below.
Let’s take a spread position where you buy 1 lot of Nifty July futures and sell 1 lot of Nifty Aug futures.
To trade 2 lots of Nifty futures, you require 57k + 57k = 114k (72k span and 42k exposure) but since you are taking a spread position, span margin required is only 7k (you receive a span benefit of 65k as calculated by the span system).
You also receive a spread benefit(also calculated by the span system) of 35k.
Your total margin benefit = span benefit + spread benefit = 65k + 35 = 1 lakh. Only a margin of 14k is required to take this position. This is shown in the image below.
Please note, you require the entire margin of 114k in your account while taking this spread position. Once the positions have entered your portfolio, the margin benefit of 1lakh is credited back into your trading account.
Example 2: Future and option hedge position
You require 57k(36k span and 21k exposure) to buy 1 lot of Nifty July futures and you require 51k(30k span and 21k exposure) to short 1 lot of Nifty July 9500 Call.
The total Span required for this position is 66k but since it is a hedged position, you only require a Span margin of 43k(you receive a Span benefit of 23k as shown in the image below.)
Please note, you require to have the entire margin of 108k while taking these positions. Once the position has entered your portfolio, you receive a span benefit of 23k and this is released back into your account.
Your total margin benefit = span benefit = 23k.
Note: Real-time span is updated 5 times a day based on volatility. The span margin calculated in the margin calculator is based on the previous day closing span values.
Hi Bharat,
Thanks for your explanation about SPAN benefit and spread benefit in F&O trading on TradingQnA. I understand:
• SPAN margin is calculated on the portfolio as a whole and only released after the positions are taken, and
• A spread position (like calendar spreads) gives both a SPAN benefit and a spread benefit, while a hedged FUT+OPT position gives just a SPAN benefit.
I want to build my own calculator that estimates:
- SPAN margin requirements for a basket of F&O positions,
- Spread benefit when positions hedge each other (like futures spreads or option spreads),
- Net margin required (SPAN + Exposure − benefits),
similar to how brokers’ SPAN calculators work. For this I need clarity on a few technical points:
- Inputs — What exact data inputs are required (e.g., underlying price, volatility, strike, expiry, risk arrays, price scan ranges)?
- SPAN calculation logic — Is there a known formula/algorithm (risk array lookup + scenario tests) we can implement, or should we approximate it?
- Spread benefit logic — How exactly is the spread benefit computed (e.g., which legs offset risk, how much margin gets reduced)?
- Exposure margin handling — Do we calculate exposure margin separately and then net out benefits?
- Example implementation — Could you share a starting point (e.g., a pseudocode, spreadsheet formula, or simple Python snippet) for a SPAN + spread benefit calculator?
I’m planning to build this in QT CPP, and may be use golang if needed. Any pointers to exchange documentation or risk parameter files used by SPAN would be very helpful.
Thanks in advance!
Language doesn’t matter. But there have been many rule changes over the years which makes historical margin calculation somewhat tricky. And you also need to have the then lotsize and option premium data. I’d suggest you to ignore it if your app can make do without it. I made a backtesting tool recently and even I chose to not take margin into consideration.
If you still want to, Zerodha (and some other brokers) have an fno margin calculator webpage. It doesn’t do calculations in the browser but uses a backend api. Your can maybe use their api.


