---
title: "How do I backtest an option strategy in India, or in Python?"
description: "Backtest an option strategy by writing the rule down before opening the data."
source_url: "https://www.rupeecase.com/learn/questions/backtest-option-strategy"
---

A backtest is only honest when the rule is fixed before the data is opened

The order of a backtest that can be checked: rule, data, costs, counts, then any change as a new test. A map of method, not a result. Source: RupeeCase method map; cost rules from NSE and SEBI circulars. As of 16 Oct 2026.
A backtest replays a rule over past data and counts what it would have done. NSE publishes end of day files that give each contract's settle price, open interest and volume, with the lot size and expiry day for each date. They hold no intraday fills, bid and ask, or order queue. NSE's terms of use limit how its data may be used and shared, so read them first.

The steps come in a fixed order. Write the rule first: the entry, the strike rule, the exit and the size. Fix the data period and hold part of it back. Charge every cost on each leg: brokerage, exchange charges, GST, stamp duty and STT, which on options falls on the premium sold and on exercise.

Count trades, not the curve. Report the number of trades and expiries, the win rate, the average win and loss, expectancy, the worst run and the drawdown. Ten trades can look like a result and still be noise. A rule changed after the test is a new rule and needs a new test.

Python is a tool, not a method. The same code will repeat any mistake in the rule, such as using a settle price that was not known at the entry, or choosing a strike after the close. Module I34 covers five biases that make a backtest look better than it is, and A28 covers options data steps. If a rule later runs live through a broker's API, the retail algo rules apply: see [the question on algo legality](/learn/questions/is-algo-trading-legal-in-india).

The school publishes no backtest of a named strategy as a result. A rule tested on a dated chain illustrates method, not performance.

**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](https://www.sebi.gov.in/reports-and-statistics/research/aug-2026/study-profitability-of-individual-traders-in-the-equity-derivatives-segment-fy25-fy26-_103835.html)

How do I backtest an option strategy in India, or in Python?Backtest an option strategy by writing the rule down before opening the data, then testing it on dated end of day chains with the lot size, expiry rules and costs of each date, over a period the rule never saw. Judge it by expectancy and drawdown across many expiries, not by a single equity curve.

LGo deeper

## Where Learn teaches this.
[Go deeperWhat a backtest is, and five biases that ruin it9 min, Intermediate](/learn/path-19/module-19-1-backtest-biases)[Go deeperBacktesting options on Indian data11 min, Advanced](/learn/path-19/module-19-6-backtesting-options)

SSources

## Go to the source.
4 sources, NSE the most cited

The publisher of each source listed below. Source: Module undefined source list.
1. [NSE, equity derivatives contract specifications (expiry cycle, lot size, settlement)](https://www.nseindia.com/static/products-services/equity-derivatives-contract-specifications) NSE
2. [NSE, terms of use for the website and its data](https://www.nseindia.com/static/nse-terms-of-use) NSE
3. [SEBI circular on safer participation of retail investors in algorithmic trading (4 Feb 2025)](https://www.sebi.gov.in/legal/circulars/feb-2025/safer-participation-of-retail-investors-in-algorithmic-trading_91614.html) SEBI
4. Chan, Ernest P., Quantitative Trading (textbook on backtesting method and its pitfalls) Book

?Questions people ask

## Related questions.
[QuestionWhat are overfitting, look ahead bias and survivorship bias?Advanced](/learn/questions/overfitting-and-biases)[QuestionMust a backtest include STT and costs?Intermediate](/learn/questions/backtest-include-stt)[QuestionWhat is walk forward testing?Advanced](/learn/questions/what-is-walk-forward-testing)[QuestionWhere do I get historical option chain and F&O data in India?Intermediate](/learn/questions/historical-option-chain-data)[QuestionDo SEBI registered algo platforms make algo trading profitable?Beginner, trap check](/learn/questions/algo-platforms-and-profitability)

[All 130 questions](/learn/questions/)

    Explore next

## Go deeper on this question.

* [ToolOption payoff builderLegs on a dated Nifty chain, breakevens and charges](/learn/tools/payoff-builder)
* [GlossaryInvesting glossary, 230 termsPlain word definitions, and the app’s own](/learn/glossary)
* [Free module 19.1What a backtest is, and five biases that ruin it9 min read](/learn/path-19/module-19-1-backtest-biases)
* [QuestionWhat are overfitting, look ahead bias and survivorship bias?A short answer with a dated chart](/learn/questions/overfitting-and-biases)
* [QuestionMust a backtest include STT and costs?A short answer with a dated chart](/learn/questions/backtest-include-stt)
* [Free module 19.6Backtesting options on Indian data11 min read](/learn/path-19/module-19-6-backtesting-options)

      Community

## Join my WhatsApp group.

      Scan the code, fillFill one short form, and join my WhatsApp group. Slides, sources, factsheets and the rebalance logs live there, and members join a daily Google Meet with me.

      New to RupeeCase? [Getting started](/getting-started) [See the terminal](/terminal)

        [Sign up for RupeeCase](https://invest.rupeecase.com/signup)
        [Join the WhatsApp group](https://forms.gle/C6HMtM1Z2GfeocQV7)

      [One form, one group](https://forms.gle/C6HMtM1Z2GfeocQV7)Scan with your phone camera

Education only, not investment advice, a research report or a recommendation to buy, sell or hold any security. RupeeCase (QC Alpha Technologies Pvt Ltd) is not registered with SEBI as an investment adviser or research analyst. Contracts and prices shown are for illustration only, come from NSE end of day files at least 30 days old, and are not recommendatory. Derivatives trading carries a high risk of loss.
