Contents Lesson 1 of 19

10 min read · practitioner

What a backtest can prove, and what it cannot

By the end of this lesson you will have the one honest sentence for the rule this course builds, written into PLAN.md with every blank filled before any code exists, a year of invented SPY bars in your fixtures for mock mode, and a commit holding both.

A backtest is the first tool in this track that can flatter you. Your watchlist could be stale and your screener could be incomplete, but neither ever told you that you were right. A backtest does, in confident percentages, and most of this course is about not being fooled by your own program.

The one honest claim

A backtest supports exactly one sentence:

Under these assumptions, on this data, a rule stated in advance would have produced this sequence of results.

Every word in that sentence is load-bearing. Under these assumptions — costs, slippage, fills, all of which you chose. On this data — one history, one vendor, one adjustment method. Stated in advance — or you are describing the past, not testing a rule. Would have — nobody traded it.

That claim is genuinely useful. It kills bad ideas cheaply, which is most of what research is. What it cannot do is tell you what happens next.

Three things it cannot prove, ever

That the rule works. One history is one sample. A rule that survived it might be sound or might have been lucky, and a single backtest cannot separate those. Unit 4 is about narrowing the gap; nothing closes it.

That you would have followed it. The equity curve assumes a person who took every trade without hesitating, including the one after a fourth consecutive loss. You do not know that person.

That the future resembles the sample. Rates, market structure, participants and fees all change. A rule fitted to one regime is a description of that regime.

The line this course does not cross

A backtest is research. It is not advice, not a recommendation, and not a claim that anybody should do anything with money.

This matters more here than anywhere else in the track, because a chart with a rising line and a Sharpe ratio beside it looks like a recommendation whether or not you meant it as one. If you publish results — a repo, a blog post, a screenshot — say plainly that it is a historical simulation and that you are not a licensed adviser. That is not a disclaimer bolted on at the end; it is an accurate description of the artefact.

The data terms are the same as in the watchlist and screener courses. EODHD's plans are, in their own words, "intended for personal use only as commercial use requires a more thorough approach to licensing and data use", and a backtest run for yourself is personal use. Selling signals derived from it is a different conversation, and the licence page in this lesson's sources is where it starts.

What you will actually have

A backtester in the same repository as your watchlist and screener: candles loaded through your existing proxy, a rule you can state in one sentence, costs visible on the first curve you ever draw, four bias tests you wrote yourself, and an exported report you would be comfortable handing to someone who wanted to pick holes in it.

The finance behind it

Why historical averages flatter almost everyone who quotes them, from the finance side: Why do "average returns" often look too good?

Try it now

Write the one honest sentence for the rule this course builds: hold SPY while its 20-day average is above its 50-day, at a cost of 10 basis points a trade (the course default; the cost lessons say what it bundles). You may write a rule you are curious about instead, but every later lesson builds the 20/50 rule, so your sentence has to describe what you actually run. Fill in every blank: which assumptions, which data, stated when. If you cannot fill in "stated in advance" — because you picked the rule after looking at a chart — you have learned something before writing a line of code.

The backtester goes into the starter that already holds your watchlist and screener. Starting here without them? Branch from the end of the screener course:

git remote add upstream https://github.com/EodHistoricalData/academy-dashboard-starter.git
git fetch upstream
git switch -c backtest upstream/ref/build-a-screener/u4
npm install

The prompt

Put your sentence at the end of PLAN.md under a heading of its own, with a line saying the results will be a historical simulation and not advice. Then start your agent in the starter, press Shift+Tab until plan mode shows under the prompt, and paste:

Read the backtest section at the end of PLAN.md. Do not edit any file.
For each part of my sentence - the assumptions, the data, "stated in
advance", "would have" - tell me what is still vague enough that two
people could build different backtests from it. Then tell me what
answering this cost in API calls. It should be none.

A good answer is comments only: it names gaps such as which close column, what a trade costs, how far back the data goes and when the rule was written, spends no call, and changes no file. Take the comments you agree with into the sentence yourself.

Mock mode needs a year of daily history to draw on, and inventing a plausible one by hand is a chore. Take ours, invented prices in the API's shape. If the starter is not yet a remote called upstream, add it with the first two lines of the block above (if you cloned the starter directly, its address is already your origin; add upstream anyway, it points to the same place); then git checkout upstream/ref/backtest-strategies/u1 -- fixtures/eod/.

Check it yourself

  1. git status after the agent's answer lists only what you changed yourself: PLAN.md, and the fixture folder once you have taken it.
  2. Every blank in your sentence is filled: the cost of a trade, the close column, the instrument and how far back its data goes, and the date you wrote the rule.
  3. "Stated in advance" is true as written. If you chose the rule after looking at a chart, the sentence says so.
  4. A sentence of its own says the results are a historical simulation and not advice.

Compare with ours

Our backtest section of PLAN.md

Under the heading "Backtest Strategies: a backtester beside the two tools":

The one honest sentence, written before any code: *Under a cost of 10 basis points a
trade and fills at the next day's open, on one year of SPY.US daily bars (adjusted close,
EODHD, pulled once and cached), a rule stated on 6 November 2026 — hold SPY while its
20-day average is above its 50-day — would have produced this sequence of results.*

The rule was chosen from the course's example, not from looking at a chart of SPY. That is
what lets "stated in advance" stay in the sentence.

It is a historical simulation. Nothing it prints is advice.

The first bar of the invented year you took for mock mode, with a dividend already folded into its adjusted close:

{"date":"2025-10-31","open":572.5,"high":575.22,"low":571.17,"close":573.28,"adjusted_close":566.2803,"volume":76451625}

The full state at the end of this unit is on the starter's branch ref/backtest-strategies/u1. To compare yours, git fetch upstream and git diff upstream/ref/backtest-strategies/u1.

Checkpoint

git add PLAN.md fixtures/eod/
git commit -m "Plan the backtest in one honest sentence, and give the mock a year of SPY"

Then answer this lesson's questions.