Monday 30 Mar 2026. Nifty closed at 22,331.40, 15.2% under its close of 26,328.55 on 2 Jan. A backtest run today sees that whole fall. A trader on 2 Feb 2026 saw none of what came after. The gap between what the test knows and what the trader knew is where most backtests go wrong. A backtest replays a rule on past data to see what it would have done. It tests a hypothesis and forecasts nothing, and each of the five biases below makes the answer look better than it was. This lesson names them, shows three on dated NSE data and says how to guard against each. Nothing here is a strategy to run, and nothing is a view on where Nifty goes.

3By the end you can

  1. Say what a backtest can and cannot show, and how to run a free end of day one on NSE files.
  2. Name the five biases: look ahead, survivorship, overfitting, cost and fill, sample and regime.
  3. Price a trade at the STT rate of its own date, and read the result of a test with that in mind.
The RupeeCase terminal on sample data: Your return three ways: why do the hero, key figure and XIRR differ?
Watch in the terminal: why do the hero, key figure and XIRR differ? A short tutorial on sample data.

The idea, plainly

What is a backtest?

Write the rule first, in plain words: what it trades, when it enters, how much it risks and when it exits. Feed it the data as it stood on each date, record every trade with its costs, and total the result. A backtest can disprove a rule cheaply. It can rarely prove one, because the past is one path and the person running the test already knows how it ended. The biases are the ways that knowledge leaks in. How to measure the result is the subject of strategy metrics.

Each stage of a backtest has its own bias

The five stages of a backtest and the bias that enters at each: data, signal, fill, costs and judgingDiagram with 5 boxes. Data to Signal; Signal to Fill; Fill to Costs; Costs to Judging.Datasurvivorship, rule changesSignallook aheadFilla settlement is not a fillCostsrates by date, slippageJudgingoverfitting, sample size
Data brings survivorship and rule changes, the signal brings look ahead, the fill and the costs bring the cost bias, and judging brings overfitting and a small sample. Source: RupeeCase illustration of a backtest pipeline. As of 17 Oct 2026.

How do I backtest an option strategy for free in India, or in Python?

NSE publishes its end of day F&O files, with each contract's settlement price, volume and open interest, on its reports page at no charge. A short Python script reads one day's file, rebuilds the option chain and applies the rule, and a loop runs it over dates. The free files cannot give the intraday price or the bid and ask, so every fill in such a test is a settlement or a close. That limit is bias four below. Keep three things beside the code: the date of each file, the rule as written before the first run, and a table of costs by date.

What is look ahead bias?

It is using information that did not exist when the trade would have been placed. The classic form is a rule that reads the day's close and trades at that same close. End of day files appear only after the market shuts, so a rule that reads a day's open interest can trade no earlier than the next session. The high and low of the day, final settlement figures and revised data are off limits too. The guard is mechanical: lag every input by one bar and check the timestamp of each. A result that looks too good often fails this check first.

What is survivorship bias?

It is testing only what still exists. Today's list of stocks with futures and options leaves out those that dropped out, so a test on it flatters any rule that picks stocks. SEBI revised the entry and exit criteria for stock derivatives in Aug 2024, so the list moves. Contracts end as well: the BANKNIFTY weekly contracts expired for the last time on 13 Nov 2024, and no later file holds one. A test must use the list and the contracts as they stood on each date, and say what it did with those that vanished.

The term this section turns on: Survivorship bias

The term this section turns on: Survivorship biasThe term this section turns on: Survivorship bias. Survivorship bias: Testing only the stocks or contracts that still exist, which leaves out those that dropped out and flatters the rule.Survivorship biasTesting only the stocks or contracts thatstill exist, which leaves out those thatdropped out and flatters the rule.
From the module glossary; every term is in the Learn glossary too. Source: Module 19.1, What a backtest is, and five biases that ruin it.

What are overfitting and data snooping?

Overfitting fits the rule to the noise of one sample. Try many versions of a rule on the same data and one will look good by luck. If twenty useless rules are each tested at the usual five percent level, the chance that at least one looks significant is 64.2 percent when the tests are independent. The chart shows how fast it climbs: 5.0 percent for one rule, 22.6 for five, 40.1 for ten and 92.3 for fifty. The guards: write the rule before testing, count every version tried and not only the winner, keep a stretch of data the rule never saw, and ask whether it has a reason to work.

Test enough rules and one will pass by luck

Chance that at least one of a number of useless rules looks significant: 5 percent for one, 23 for five, 40 for ten, 64 for twenty and 92 for fifty1 rule 5.0; 5 rules 22.6; 10 rules 40.1; 20 rules 64.2; 50 rules 92.3.Chance one useless rule passes at five percent1 rule5.05 rules22.610 rules40.120 rules64.250 rules92.3
Plain arithmetic for independent tests: the chance that no rule passes shrinks with every rule added, and the bar shows the rest. It is why the count of versions tried matters as much as the winner. Source: RupeeCase arithmetic, no market data. As of 17 Oct 2026.

Must a backtest include STT and costs?

Yes, by date, and the costs are more than STT. STT is charged on the premium of a sold option, the exchange charges a fee on every trade, SEBI takes a turnover fee and GST sits on the exchange charge. Brokerage and slippage come on top. The rates change. STT on a sold option's premium was 0.0625% from 1 Apr 2023, 0.10% from 1 Oct 2024 and 0.15% from 1 Apr 2026. A test that spans those dates with one rate misprices every trade. At the three rates the STT on one sale is Rs 5.29, Rs 8.47 and Rs 12.70, as the chart shows.

The same sale paid more STT at each rate change

STT on selling one lot of the 24,000 put at its 2 Feb 2026 settlement price at the three rates in force from April 2023, October 2024 and April 2026: it rises with each changeRate of Apr 2023 5.29; Rate of Oct 2024 8.47; Rate of Apr 2026 12.70.STT on selling one lot, rupeesRate of Apr 20235.29Rate of Oct 20248.47Rate of Apr 202612.70
One lot of 65 units of the 24,000 put sold at 130.25 a unit, premium Rs 8,466. Only the STT rate differs between the bars. Source: NSE end of day data and NSE STT circulars, computed by RupeeCase. As of 2 Feb 2026.
Read one more paragraph, 42 words

SEBI's August 2026 study of FY26 shows what is at stake in aggregate. Among individual traders, 87.7% made a net loss after costs and 82.1% before them, and transaction costs ran to about Rs 25,000 crore a year in FY25 and FY26.

What are sample bias and regime bias?

A window with one crash holds one lesson, and a window with none holds none. The 20 day realised volatility of Nifty ran from 5.2% to 29.5% within the 300 sessions in the files. The rules change as well. The Nifty lot was 75 units in mid 2025 and 65 from January 2026. The Nifty expiry moved from Thursday to Tuesday on 1 Sep 2025. From 7 Dec 2026 the expiry settlement price becomes a volume weighted average over the last thirty minutes of trading, and for expiries before that date it is the index close. A test must carry the rule in force on each date.

One rule meets calm and stormy months, not one market

Twenty day realised volatility of Nifty from 1 Jul 2025 to 15 Sep 2026, annualised: it moves between a quiet floor and a sharp spike in April 2026Nifty 20 day realised vol: from 10.1% at 1 Jul 2025 to 7.3% at 15 Sep 2026, high 29.5% at 8 Apr 2026, low 5.2% at 1 Sep 2026.5%10%15%20%25%30%Jul 2025OctJan 2026AprJul7.3%
Twenty day realised volatility of the Nifty 50, annualised, from daily closes. A rule tuned on the quiet stretch meets the spike with no warning. Source: NSE end of day data, computed by RupeeCase. As of 15 Sep 2026.

Model, not market data

A short sample of a seller shows the wins and misses the tail

Model, not market data. Modelled weeks for the seller of one far Nifty put: many small wins and a few large losses that cancel themProfit: 19 weeks in 20 15,435; Loss, all 1 weeks in 20 −15,449; of which up to 3x premium −219; of which 3 to 10x premium −1,763; of which over 10x premium −13,467.Per 20 weeks, one lot, before costs; L is lakhProfit: 19 weeksin 20+0.15LLoss, all 1 weeksin 20−0.15Lof which up to 3xpremium−0.00Lof which 3 to 10xpremium−0.02Lof which over 10xpremium−0.13L
Each bar is the total, in lakh of rupees, for one lot over 20 weeks. Prices are fair, so nobody starts with an edge. The losses come from the weeks the window rarely contains. Inputs: one lot of 65 units of the Nifty 22,500 put sold at its settlement premium of Rs 12.65 a unit on 10 Jun 2026, expiry 16 Jun 2026; the forward 23,229.26 and the option's own implied volatility 16.16% over 6 calendar days; the index at expiry follows a lognormal curve around the forward; 20 weeks; before costs and interest. Source: RupeeCase model, inputs from NSE end of day data. As of 10 Jun 2026.
Read one more paragraph, 60 words

A seller of far options is the sharpest case. In a model with fair prices, the seller of a far Nifty put wins 19 weeks in 20, and the tail week that gives it all back is expected only 0.7 times in that window. A typical sample of that length meets none, so its record looks like steady gains.

Worked example: one sold put, two sets of rates

Take the Nifty 24,000 put of the March expiry on 2 Feb 2026, settled at 130.25 a unit. One lot of 65 units sold at that price brings in Rs 8,466. A test that fills at the settlement price books exactly that. The table prices the statutory charges of the sale at the rates in force that day and at the rates from 1 Apr 2026.

One sold lot, rupeesRates of Oct 2024Rates from Apr 2026
STT on the premium8.4712.70
Exchange charge2.973.01
SEBI turnover fee0.010.01
GST on the exchange charge0.530.54
Statutory total11.9716.26
Share of the premium0.14%0.19%
Read one more paragraph, 110 words

The total rose 35.8% across the two columns, yet it stays a small share of the premium, 0.19%, for a trade held to expiry. Brokerage and slippage are larger. An assumed slippage of one rupee a unit costs Rs 65.00 on one lot, 4.0 times the statutory total at the new rates. The fill is the largest assumption of all. A strike that traded a handful of contracts gets a settlement price that is not the price of a trade, so a test that fills there trades at a price that never stood as an order. The cost lesson is in the real cost of an F&O trade.

The common mistake

The belief: My backtest looks great, so the strategy works. Run it through the five stages. Did the signal use anything unknown at the time? Does the list of stocks or contracts include what has vanished? How many versions were tried before this one, given that twenty are enough for a lucky pass in 64.2 percent of cases? Were the costs those of each date, and was the fill a trade or a settlement? Did the window hold more than one regime? A good curve that passes all five is a reason to test further, on data the rule has not seen. SEBI now allows only registered advisers, research analysts and empanelled algo providers to state past performance, and only as risk and return figures verified by a recognised agency, operating since 4 May 2026. A backtest on a screenshot is not that.

The RupeeCase terminal on sample data: Model history or your portfolio: which numbers am I looking at?
Watch in the terminal: which numbers am I looking at? A short tutorial on sample data.

Key takeaways

  • A backtest tests a hypothesis. It does not forecast anything.
  • Look ahead bias is a timing error: lag every input by one bar.
  • Test the list and the contracts as they stood on each date.
  • Count every version tried. Enough useless rules will pass by luck.
  • Costs have rates by date, and a settlement price is not a fill.
  • A window with no crash tells nothing about crashes.

Two terms to hold on to from 19.1

Two terms to hold on to from 19.1Two terms to hold on to from 19.1. Backtest: A replay of a written rule on past data to see what it would have done. It tests a hypothesis and does not forecast. Look ahead bias: Using information in a test that did not exist at the time of the trade, such as a close used to trade at that same close.BacktestA replay of a written rule on past data to seewhat it would have done. It tests a hypothesisand does not forecast.Look ahead biasUsing information in a test that did not existat the time of the trade, such as a close usedto trade at that same close.
From the module glossary. Source: Module 19.1, What a backtest is, and five biases that ruin it.

Before you trade. Derivatives trading carries a high risk of loss. SEBI's study "Profitability of Individual Traders in the Equity Derivatives Segment (FY25 to FY26)" (August 2026) found that 87.7% of individual traders in equity F&O made net losses in FY26, with aggregate net losses of Rs 91,685 crore. Read the SEBI study