How to Backtest an Options Strategy: A Step by Step Guide
To backtest an options strategy you replay a fixed set of entry and exit rules against historical option prices, subtract every real cost, then judge the result on risk adjusted numbers rather than total profit. The work is mostly data preparation and honest accounting, not clever code.
A backtest tests whether your rules had an edge in the past after costs, and nothing more; it is not a prediction, and it cannot tell you whether you will follow those rules when a position is losing money.
Treat the output as a filter that rejects bad ideas, not a promise about good ones. What follows covers the data, the rules, the cost model, a numeric example, the metrics worth reading, and how a backtest lies.
The data problem is most of the problem
Equity backtests need one price series per stock. Options backtests need a price for every strike and expiry on every day.
What your dataset must contain
- Date stamp, underlying spot, strike, expiry date, option type and settlement or close price.
- Bid and ask if you have them, because the mid price is what you should assume, not last traded price.
- Open interest and volume, so you can drop strikes too illiquid to trade.
- Lot size history, since exchanges revise lot sizes and using today’s figure for a trade from three years ago corrupts every rupee amount.
- A record of expiry day changes, because those schedules have shifted.
End of day data is enough for positional strategies held for days or weeks. Anything intraday needs minute level data, where the quality gap between free and paid sources widens sharply.
The illiquid strike trap
A deep out of the money option may show a close of Rs 0.60 with no trades that day. A backtest will sell it 200 times and report a profit you could never have collected. Filter by open interest and volume.
Write rules a machine could follow
Vague rules produce flattering backtests, because you resolve ambiguity in your favour. Every rule needs a number.
- Entry trigger: exact condition and time of day. “Sell at 9:20 AM on the Monday after weekly expiry” is a rule. “Sell when volatility looks high” is not.
- Strike selection: by delta, by distance in points, or by percentage from spot. Pick one and fix it.
- Position size: number of lots, and whether it scales with account value.
- Stop loss: a multiple of premium received, a rupee amount or an underlying level, checked on close or intraday.
- Profit target and time exit: a percentage of the credit collected, and the day and time you close regardless.
- Skip conditions: results days, holidays, or a volatility level above which you do not trade.
Write these down before you look at any results. Once you have seen the equity curve you are no longer testing a hypothesis.
Model your costs honestly
This is where most retail backtests fall apart. A strategy clearing 3% a month before costs can lose money after them.
| Cost item | Applies | How to model it |
|---|---|---|
| Brokerage | Per executed order | Flat rupee amount per leg, entry and exit |
| STT on option sale | 0.15% on sell side | On premium value of the sold option |
| STT on exercise | 0.15% on settlement value | On intrinsic value, paid by the buyer |
| Exchange charges | Percentage of premium turnover | Check the current rate on the exchange website |
| GST and SEBI fees | On brokerage and exchange charges | A percentage of those two items |
| Slippage | Assumed fill versus real fill | Assume you cross half the bid ask spread per leg |
The exercise line matters most. Because STT of 0.15% applies to settlement value rather than premium on an exercised option, letting a small in the money option expire can cost far more than squaring off. Code around it by forcing a square off before expiry.
A worked example: one year of weekly short straddles
Suppose you sell a Nifty at the money straddle weekly and close on expiry day, with a stop loss at twice the credit. Assume a lot size of 75, confirming the current figure on the exchange website. Over 48 trades:
- Average credit collected: Rs 260 per unit, so 260 x 75 = Rs 19,500 per trade.
- 34 winners averaging Rs 6,000: 34 x 6,000 = Rs 2,04,000.
- 14 losers averaging Rs 14,000: 14 x 14,000 = Rs 1,96,000.
- Gross profit and loss: 2,04,000 minus 1,96,000 = Rs 8,000.
Now add costs. Each trade has four legs, two sold at entry and two bought back at exit. Assume Rs 350 per trade for brokerage, STT, exchange charges, GST and half spread slippage. Across 48 trades that is Rs 16,800.
Net result: 8,000 minus 16,800 = a loss of Rs 8,800 for the year. The strategy won 71% of its trades and still lost money. Our walkthrough on calculating options profit and loss shows the same maths on one position.
Which metrics actually matter?
Total profit is the least useful number in the report. Read these.
- Maximum drawdown in rupees and as a percentage of capital committed. This decides whether you could have stayed in the seat.
- Average win divided by average loss, read alongside win rate. Above, that ratio was 6,000 to 14,000, so 71% failed.
- Longest losing streak and its dates. Six losses in one month feels different from six across a year.
- Return on margin blocked, not on premium collected, since margin is the capital tied up.
How do you know your backtest is lying to you?
Four failure modes account for nearly every unpleasant surprise.
Look ahead bias: using information not available at the decision moment, such as the day’s close to trigger an entry supposedly made at 9:20 AM.
Overfitting: tuning a stop loss from 1.8x to 2.1x because it improves the result. If a strategy only works at one setting, it does not work.
Regime bias: testing only a period where volatility behaved one way. Run the rules through a calm year and a violent one separately, then compare. Our note on implied volatility explains why regime matters here.
Unrealistic fills: assuming last traded price on illiquid strikes, or ignoring that a stop loss during a gap executes far from your level.
Survive all four and you can forward test on paper, then trade minimum size for a quarter while logging live results against backtested ones. A persistent gap is almost always cost or slippage, and many errors in our piece on common options trading mistakes appear first as that gap.
Plain risk note: past results, backtested or live, do not carry forward. Options selling can produce long stretches of small gains and then one loss that erases them.
Frequently Asked Questions
How many trades do I need before a backtest means anything?
More than most people use. A few dozen tells you almost nothing, because a single outlier dominates the result. Aim for at least a hundred trades spanning calm and volatile periods. If your rules generate ten trades a year, you need many years of data, not one good year.
Can I backtest options strategies in Excel?
Yes, for end of day positional strategies with a few legs. Excel becomes painful once you need dynamic strike selection across thousands of rows, or minute level data. Python for the engine with a spreadsheet for sanity checking is the practical middle ground for most retail traders.
Where do I get historical Indian options data?
Exchanges publish daily bhavcopy files with settlement prices, open interest and volume for the F&O segment, and paid vendors sell cleaned historical chains. Start with the exchange files since they are authoritative, then decide whether the cleaning work is worth paying to avoid.
Should I include margin requirements in the backtest?
Yes, at least approximately. Without it you cannot compute return on capital, and you miss the trades where a margin increase would have forced you out of an otherwise profitable position. Check how the result changes if margin were 30% higher than you assumed.
How often should I re-run a backtest on a live strategy?
Once a quarter is reasonable, extending the window with the newest data rather than re-optimising the parameters. If you change settings every time performance dips, you are curve fitting in slow motion and your reported edge belongs to the past, not to the rules you will actually trade.
Key Takeaways
- Options backtesting is a data problem first: you need every strike and expiry, plus historical lot sizes, or your rupee figures are wrong.
- Write every rule as a number and a timestamp before you look at any result.
- Model brokerage, STT at 0.15% on option sales, exchange charges, GST and half spread slippage on each leg.
- Force a square off before expiry, since STT on exercised options applies to settlement value, not premium.
- Judge results on maximum drawdown, average win versus average loss and return on margin, not total profit. A 71% win rate produced a yearly loss once Rs 350 per trade of costs was applied across 48 trades.




