Contents Lesson 18 of 19

14 min read · professional

Publish the report, and what the exam checks

By the end of this lesson you will have a report generated by your backtester — the claim, parameters, data, assumptions, results, robustness, tests and limitations, with the number of parameter sets you tried — and a clear picture of the exam that follows.

The artefact of this course is not the equity curve. It is a document that lets a sceptical reader decide how much to believe it.

What the export contains

One file, generated by the code rather than written by hand — a report you typed is a report that drifts from the run it describes:

  • The claim, in the one honest sentence from lesson 1, with the blanks filled.
  • Parameters, the whole struct, cost and slippage included.
  • Data: symbol, first and last bar, bar count, which close column, vendor and date pulled.
  • Assumptions: fill rule, cost in bps, slippage in bps, universe and what it excludes.
  • Results: gross and net return, cost as a fraction of gross, max drawdown, time under water, trades, time in market, and the buy-and-hold control on identical terms.
  • Robustness: in-sample against out-of-sample, the neighbour-parameter table, and the number of parameter sets tried.
  • Tests: which of the three leak tests ran and that they passed, with the shuffle check's numbers beside them and no pass mark.
  • Not tested: regimes outside the sample, and the delisted universe if you ran on survivors.

That last section is what separates a research note from a sales pitch. A report with no limitations section is telling you something about its author.

Say what it is

A historical simulation, not advice, and you are not a licensed adviser. Put it at the top rather than in small print at the bottom, because a chart with a rising line reads as a recommendation to almost everyone who sees it.

Publishing the code is fine and good — it is the portfolio piece. Publishing the data is a different question: EODHD's terms are personal use, so ship the code and the report, not a copy of the price history.

What you can now do that has nothing to do with backtests

You can test for correctness in a domain with no oracle. There is no right answer to compare against, so you built properties instead: change the future and the past must not move; add data and history must not change; every fill inside its bar. That technique — property-based testing — transfers to anything where you cannot enumerate the right answers.

You know that the flattering result is the suspicious one. A first attempt that looks brilliant is a bug prior. This is a general engineering instinct, and it is rarer than it should be.

You state assumptions as data. Parameters in a struct, printed in the output. A result you cannot reproduce is not a result.

What the exam asks

Ten questions, seventy percent to pass, twenty-four hour cooldown, drawn from a pool several times the size of one paper, so a retake is a different paper. Every fixture is fixed. Expect:

  • Find the leak. A signal function is shown; you name the index or the operation that reads the future.
  • Pick the column. Given the AAPL bars across 2020-08-31, say what the return is on each close and which is correct.
  • Count the cost. Given a turnover and a bps figure, say what the strategy pays per year.
  • Read the drawdown. Given a small equity series, compute max drawdown against the running peak.
  • Judge the universe. Given the live and delisted counts, say which strategies the bias most damages.
  • Judge the claim. Given a result and a report, say what is missing before anyone should believe it.

Try it now

Build the report with the prompt below, then hand it to your assistant with one instruction: "argue that this result is not trustworthy." Read the objections and answer each one either in the report or in the code. When you cannot answer an objection, that is the honest limitation — write it in the "not tested" section rather than deleting the question.

The prompt

The agent cannot see this lesson, so the prompt carries the report's contents. Mock mode on, plan mode on, and paste:

Plan first. Add a report to the backtest page: a link "Download the
report" to /backtest/report, which answers with one Markdown file
generated by code from the run it describes, using the same address
parameters (fast, slow, cost, slippage, fill) and the same cached
history as the page. Downloading it makes no API request.
The file starts with a title, then a quoted line saying it is a
historical simulation, not advice, and that the author is not a licensed
adviser. Then these sections, in this order:
- Claim: the one honest sentence from PLAN.md with every blank filled
   from the run (cost, slippage, fill rule, bar count, first and last
   date, the date the rule was stated, the rule itself).
- Parameters: the whole parameters object as JSON.
- Data: symbol, first and last bar, bar count, which close column
   returns use, source and date pulled. If the bars are the mock
   fixture, say so, and say that they are invented prices, not market
   data.
- Assumptions: fill rule, cost and slippage in bps, the universe and
   what it leaves out, one unit held or none.
- Results: strategy and buy and hold side by side, on the same bars and
   costs: gross and net return, cost as a share of gross, maximum
   drawdown, time under water, return over drawdown, trades, time in
   market.
- Robustness: the in-sample result; the out-of-sample result as the
   run log's last oos line recorded it, never run again for the
   report, because generating a report is not a look (if the log
   holds no oos line, say it has not been run); the
   neighbour-parameter table; the number of parameter sets the run
   log holds for this symbol, not counting the oos lines; and the
   number of looks out of sample.
- Tests: the future-mutation, truncation and fill-range checks, run
   on this data when the report is generated, each marked passed or
   FAILED, not copied from the last npm test. Then the shuffle
   check's median beside the real result, as two numbers with no
   pass mark: it is not a leak test.
- Not tested: the history window and the regimes outside it, walk-forward
   over several periods, other instruments and a universe with delisted
   names, and whether anyone would have followed the rule.
Keep the date the rule was stated in one constant. Tests first in
tests/report.test.ts: the sections appear in this order, the first lines
say historical simulation, not advice, the parameters and the number of
attempts are printed, mock prices are labelled as invented, and the
text contains no FAILED. Before writing, read the honest sentence in
PLAN.md and tell me if it describes a different rule, cost or fill than
the code runs. Run npm test, typecheck and check:leak, then show me the
diff.

A good answer adds a route, a report builder and its test, changes the backtest page for the link, spends nothing, and either confirms that your PLAN.md sentence matches the code or tells you where it does not. If it does not, fix the sentence yourself: the report must describe the rule that ran.

Check it yourself

  1. curl -s localhost:3000/backtest/report (or the link on the page) prints Markdown whose first lines are the title and a quoted line saying it is a historical simulation, not advice.
  2. The section headings are, in order: Claim, Parameters, Data, Assumptions, Results, Robustness, Tests, Not tested.
  3. Open localhost:3000/backtest/report?fast=10&slow=30: the Parameters section and the numbers change with it. The report describes the run of those parameters, not of the defaults.
  4. In mock mode the Data section says the prices are invented. A report that quotes a return without saying whose prices produced it is the failure this section exists to prevent.
  5. The number of parameter sets matches the lines in .cache/runs.jsonl for your symbol that are not marked oos, and downloading the report twice adds no line. On mock nothing is logged by design, so the report prints 0 sets and says the out-of-sample run is not in the log; the counts are meaningful only after live runs on a cached history.
  6. The Claim sentence says the same rule, cost and fill as the sentence in PLAN.md. Where they differ, the sentence in PLAN.md is the one to fix.
  7. The meter does not move when you download the report.

Break it on purpose

In mock mode, make the signal window centred, as in the first lesson of this unit, and download the report again: the Tests section says FAILED. A report that prints a fixed "passed" is a report that cannot disagree with the code. Put the window back and download it once more.

Argue with it

With the report built, hand it to your agent: Fetch localhost:3000/backtest/report and argue that this result is not trustworthy. List each objection with the section it concerns. Change no file. If every objection holds up, that is a result too; ask which one it is least sure of and check that one first.

Compare with ours

The top of our report
# Backtest report: SPY, 20/50 moving-average rule

> A historical simulation, not advice. Nobody traded these results, and the author is
> not a licensed adviser.

## Claim

Under a cost of 10 bps a trade, 5 bps of slippage against each trade and fills at the
next bar's open, on 251 daily bars of SPY (2025-10-31 to 2026-10-30, adjusted close,
mock fixture, pulled 2026-11-06), a rule stated on 6 November 2026 — hold SPY while
its 20-day average is above its 50-day average — would have produced the results below.

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

Checkpoint

npm test && npm run typecheck
git status   # only the files this step touched, no .env*
git add -A
git commit -m "Publish the report: generated from the run it describes, limits included"

Then answer this lesson's questions.