Get your API key

Lesson 1 of 5

What a backtest really is (and your project setup)

A backtest replays an exact rule on past prices with costs. Write the rule, set up Python, and give your agent safe project rules.

9 min Free

Education only. This is not investment advice and nothing here is a buy or sell recommendation. Trading carries risk of loss, and past results do not predict the future. Backtests are hypothetical: practise on paper only, never connect broker API keys or place live orders from these lessons. For personal advice, talk to a SEBI-registered Investment Adviser.

One step at a time, like flipping pages.

By the end of this lesson you will know what a backtest can and cannot tell you, write a trading rule exact enough to test, and have a Python project ready with safe rules for your AI agent.

You need: a laptop with Python 3 installed, a coding agent (Claude Code, Codex or OpenCode; see the setup guides), the basics from Run a project · Time: 9 minutes

  1. A backtest replays a written rule on past prices and asks: if someone had followed this rule exactly, with real costs, what would have happened?

    It can tell you:

    • whether the rule did anything different from simply holding, after costs,
    • how bad the worst fall was (the drawdown), and how often the rule traded,
    • whether your idea even makes sense once written down exactly.

    It cannot tell you what will happen next. Markets change, and a rule that worked in one period often fails in the next. A backtest is a hypothesis test, not a forecast.

    Why?

    SEBI found that 7 in 10 individual intraday traders lost money in FY23, and 87.7% of individual equity-derivatives traders made net losses in FY26. Many of them traded ideas that "looked right" on a chart. Testing honestly, before believing, is the skill this course teaches.

    Careful

    Education only. This is not investment advice, and no index or stock here is a recommendation. We use NIFTY 50 data only as test data. Nothing in this course connects to a broker or places orders.