# Is the Backtest Lab the same engine as the research harness?

5 Oct 2026, lane m14. Checked against the code on `lane/m14-1005` (base 8111f058).

**No. They are two engines, different by design.** The Lab (`src/lib/lab/engine.ts`, `ENGINE_VERSION = "lab-1.0.0"`, contract `docs/product/lab-contract.md`) answers "how did this one rule do on this one stock, against holding it and against random entries?". The research harness (`research/hunt2/harness.mjs` + `ledger.mjs`, `METRICS_VERSION = 2`) answers "out of every strategy we have ever tried, does any one beat an equal-weight benchmark after correcting for how many we tried?". A Lab result and a published research result for "the same rule" will not match, and should not be expected to.

## Where they share code

Only one function: `mulberry32` from `src/lib/quant/stats.ts` (the seeded RNG), imported by `engine.ts:14` and `harness.mjs:23`. Even that is used with different seeds and different placebo designs. Nothing else is shared:

- Indicators: the Lab uses `src/lib/indicators.ts` (`sma`, `ema`, `rsi`, `atr`, `engine.ts:13`). The harness has its own incremental copies inside `makeIndicators()` (`harness.mjs` ~190-260: `ctx.sma`, `ctx.ema`, `ctx.rsi`, `ctx.atr`, `ctx.donchian`). Both are Wilder RSI and SMA-seeded EMA, so they should agree to rounding, but they are separate code. No parity test ties them.
- Costs: the harness imports `slippageFor` / `DEFAULT_SLIPPAGE` from `src/lib/quant/walkforward.ts` for crypto; the Lab uses `DEFAULT_COST_BPS` from `src/lib/lab/types.ts` (5 bp a side for US stocks, chosen in `api/_lab.ts:462`).
- Data: the Lab reads `src/lib/lab/data/equs-daily.json` (Databento EQUS.SUMMARY, 50 US symbols, 2024-07-01 to 2026-10-02, split-adjusted, not dividend-adjusted) or synthetic bars. The harness reads `research/hunt2/data.mjs` caches (Binance crypto, 40 US large caps, 25 ETFs; discovery only, cut at 2025-03-15). No dataset overlaps in both engines over the same dates with the same adjustment.

## Where they differ

| | Backtest Lab (lab-1.0.0) | Research harness (hunt2 v2) |
|---|---|---|
| Unit of test | one rule, one symbol, one period | one strategy over a universe (equal weight across assets trading that day), or a cross-sectional `rank()` portfolio |
| Rule language | fixed schema `tickfloor.lab.rule/1`: long only, entry/exit conditions on sma/ema/rsi/highest/lowest/atr/price, `maxBars` 1 to 250, optional stop and target %, % of cash sizing (`types.ts`) | any JavaScript `signal(bars, i, ctx)` returning -1/0/1, or `rank()` weights; long/short allowed; lookahead guarded by a read-only bar view and truncation re-runs (`harness.mjs` makeView, runSignalMode) |
| Fills | signal at bar close, fill at next open; stop and target fill intrabar, stop first if both touched; gap through stop fills at the open (`EXECUTION_CONVENTIONS`, `engine.ts` exitPath) | position decided at bar i's close earns close(i) to close(i+1); no intrabar stops or targets, no next-open fill (`assetReturns`) |
| Money | integer cents, quantity floored to the dataset step, $10,000 start | fractional daily returns, no cash or share rounding |
| Costs | per-side bps on both legs (default 5 bp for US stocks); also a "harsh" 2x run | 0.05% a side stocks/ETFs; crypto 0.10% + measured slippage; charged on every change in position |
| Benchmark | buy-and-hold of the same symbol, and it **pays** the same entry and exit costs | equal-weight daily-rebalanced long of the same assets, **no** costs |
| Random control | 1000 draws, stratified random entry bars, same exit rule, sizing and costs, asking for the strategy's trade count; reports the strategy's percentile on net return and its relation to the 95th percentile | 200 seeds that move the strategy's own trades (same lengths and directions) to random non-overlapping spots; reports the percentile on mean daily log return and on Sharpe (`shuffledPositions`, `controlSummary`) |
| Inference | none: no p-value, no bootstrap, no correction. Words are limited to beat / did not beat / matched "in this sample", status is always "Exploration" | one-sided circular block bootstrap p on daily log excess vs the benchmark, a Sharpe-difference bootstrap, split-half check, then Benjamini-Hochberg over every distinct run in `ledger.jsonl` (707 tests at the base of this lane) |
| Multiple testing | counts versions per experiment and per account (`attempts`), shown to the user, but no correction | every distinct source that traded is one test in the FDR family; editing a strategy and re-running adds a test |
| Output | an immutable receipt with every trade, event and equity point, publishable at `/lab/runs/<id>` | `results/<id>.json` plus a ledger row; the public registry is rebuilt from the ledger (`scripts/research/build-registry.mjs`) |

## What this means for the trending-1005 articles

- Every number in the five articles comes from the harness (or from earlier harness-based or intraday studies, named per article), not from the Lab.
- The articles link to the Lab as "try a version of this rule yourself". The Lab only accepts `?symbol=` in its URL (`LAB_ROUTE_QUERY` in `types.ts`), so a prefilled rule link is not possible without a Lab change. The articles link to `/lab?symbol=<free symbol>` and spell out the rule to enter.
- A reader who rebuilds the rule in the Lab will get a different number: one symbol instead of a basket, 2024-07 to 2026-10 instead of the discovery window, next-open fills, a benchmark that pays costs, and no multiple-testing correction. The articles say so.
