Contents Lesson 17 of 19

9 min read · professional

The history wall

By the end of this lesson you will have your earliest bar and bar count in PLAN.md, the three history lines filled in from your own numbers, and your strategy's maximum drawdown on all of your in-sample history beside the same run from 2015 on.

The watchlist's wall was freshness. The screener's was breadth. This one is depth, and it bites in a way the others did not: it removes the specific years that would have told you whether your rule is any good.

Find your own edge of the world

One call, and you know:

const bars = await load("AAPL.US");            // no date range; use the instrument your backtester runs on
console.log(bars[0].date, bars.length);

On the account this course was written against — an unrestricted one — that prints 1980-12-12 and 11516. Yours will differ, and the difference is the wall. Run it now for the instrument your backtester runs on, with your own free key (the shared demo key serves AAPL.US but answers 403 for SPY.US), and write the date in PLAN.md, because every claim you make later is bounded by it. If you only have the mock year, its first bar is your edge, and the line says so.

What gets cut, and why it is the wrong part

History is cut from the old end, and the old end is where the interesting regimes are. Shorten the history and the sample loses, in order: 2008 first, then 2018's rate scare, and 2020's crash and recovery last.

The 2008 figures from the previous lesson are the point. SPY fell 55.2% from its 2007 peak and took 1,224 trading days to recover. A backtest starting after 2009 still meets 2020 and 2022, but it never meets a drawdown that took nearly five years to come back — and that is the specific experience a rule needs to survive. The maximum drawdown it reports is then a fact about your window rather than about your rule.

Which produces the specific failure this wall causes: your risk numbers are the ones most damaged by a short history. Return might be roughly right. Maximum drawdown, time under water, and the walk-forward from the previous lesson are all measurements of rare events, and a short sample contains no rare events by construction.

The wall the other courses did not have

Note how this differs from breadth. In Build a Screener you could at least see that your universe was partial. Here, a short history produces a complete-looking result — a smooth curve, a modest drawdown, a plausible Sharpe if you computed one — that is confidently describing a calm decade.

There is no in-band signal for it. The tool cannot tell you. Only the first date can, which is why it goes in the report.

Write it into the report

Three lines, alongside the parameters:

History available:   ____-__-__ to 2026-08-25   (____ bars)
Regimes in sample:   __________________________
Regimes NOT tested:  __________________________

That third line is the honest output, and it usually reads "2008, 2020, every rate cycle before 2015".

What upgrading changes, precisely

Nothing in your code. Same backtester, same rule, same tests — with the years that would falsify it. And the same honesty as the other two walls: if you are testing a single instrument on a recent window and you know that is what you are doing, it fits, and you should not pay for anything. Live pricing is on the pricing page and deliberately not quoted here; a number written into a lesson goes stale and then lies to whoever reads it next.

Try it now

Find your earliest bar, then run your strategy twice: once on everything you have before the split date, once on 2015-onward only. Compare the maximum drawdowns. The difference between those two numbers is exactly what the wall is hiding from you, and seeing it once is worth more than being told.

On a free plan your first bar is about a year back, so the two runs are one run. Trim to a date inside your year instead, so the mechanism is still yours, and read the 2008 figures above as the picture a longer history gives: that gap is your "Regimes NOT tested" line.

The prompt

Mock mode on, plan mode on:

Plan first. Add a from parameter to the backtest page, read from the
address and checked like the others, that trims the cached bars
before the run, so a shorter window costs no request. Then, from my
history in .cache/eod/, or from the mock year's fixture if there is no
cache (say which), tell me my earliest bar, my bar count, and my
strategy's maximum drawdown on the bars before SPLIT_DATE, all of
them and from 2015-01-01; stay in sample, so this is not another
look out of sample.
Draft the three history lines at the end of PLAN.md (available,
regimes in sample, regimes not tested) from those numbers, and show me
the diff. I will edit the regimes myself.

A good answer changes params.ts and the page, drafts three lines in PLAN.md, and reads only the cache: the meter does not move.

Check it yourself

  1. The earliest bar the agent reported is the first date under your live chart.
  2. Live, ?from=2015-01-01 reruns with the meter unmoved: a trim, not a request.
  3. Two maximum drawdowns sit side by side. If your history starts after 2015 they are the same run, and the gap the lesson describes is your whole "not tested" line.
  4. "Regimes NOT tested" names years rather than a feeling — 2008 at least, if your first bar is after 2009 — and you edited the agent's draft rather than accepting it.

Compare with ours

Our trim and our three lines
// src/app/backtest/page.tsx
const window = params.from ? bars.filter((b) => b.date >= params.from!) : bars; // a trim, no request

Ours are written for the year of mock bars, which is what the reference branch runs on:

History available:   2025-10-31 to 2026-10-30   (251 bars, invented: mock mode)
Regimes in sample:   none — invented prices belong to no history
Regimes NOT tested:  2008, 2020, 2022, and every rate cycle before this window

The full state at the end of this unit is on the starter's branch ref/backtest-strategies/u4.

The reference backtest page at the end of unit 4, on invented fixture prices

Checkpoint

npm test && npm run typecheck
git status   # only the files this step touched, no .env*
git add -A
git commit -m "History wall: my first bar, what my sample holds, and what it never met"

Then answer this lesson's questions.