BL-IS-003: Walk-Forward Harness
BIJECTIVE LABS
BL-IS-003: Walk-Forward Harness
Status: RELEASED
Classification: PUBLIC
Revision: 1
Date: 2026-09-07
1. What it measures
The result a strategy would have produced if every parameter it depends on had been estimated only from data available at the time of the decision.
That is a different quantity from what a conventional backtest reports, and on this substrate the difference was 235 basis points.
2. The defect it was built to eliminate
A pairwise mean-reversion strategy reported a backtest return of +180 basis points at an 80 percent win rate. Re-run through this harness on the same instruments it returned -55 to -68 basis points at a t-statistic between -4.0 and -5.9, on every configuration tested. Live, it returned -25.5.
The defect was one line. Pair selection computed the hedge ratio across the entire price panel and the resulting coefficient was then used to simulate trading over that same panel.
beta, alpha = ols( logP[:, i], logP[:, j] ) fitted on the full window
traded on the full windowThe backtest did contain an out-of-sample check. It gated which pairs were selected using a seventy-thirty split, and it never touched the profit calculation. The presence of a split in the code created the appearance of discipline while the quantity that actually mattered was fitted on the future.
BL-IN-003 is the case study.
3. The three changes that fix it
Fitting takes an explicit bound. Selection and estimation can never see past it.
Ptr = P if train is None else P[:train]Estimation refits at every decision point on trailing data only.
at each bar t:
window = [t - L, t - 1]
beta_t = ols(window)
mu_t = mean(spread over window)
sigma_t = sd(spread over window)
z_t = ( spread_t - mu_t ) / sigma_tEvery quantity carries a subscript t and is computed from data strictly before t. The look-ahead defect in section 2 is visible in this notation as a missing subscript, which is the point of writing it this way.
Parameters freeze at entry. When a position opens, the beta, mu and sigma in force are held for the life of that position. Refitting mid-position would let information from after the entry decision alter a trade already taken.
Only then are exit, stop and timeout evaluated.
4. Cost, matched to live
The harness applies the realised cost model rather than a nominal fee.
c_rt = fee_per_leg * ( 1 + beta ) + spread_per_legThe ( 1 + beta ) term is the one most often omitted in pair strategies. A
hedged pair transacts two legs of unequal size, so the round trip is not twice a
single leg's cost. At a hedge ratio of 1.4 the cost is 2.4 legs, not 2.
Getting this wrong understates cost by a factor that scales with the hedge ratio, which means it understates most on exactly the pairs a selector would prefer.
5. Interface
walk_forward(prices, params, train_bound, lookback, cost_model) -> Result
prices panel of log prices, T by N
params entry, exit, stop, timeout thresholds, fixed at pre-registration
train_bound index before which fitting may see data; None for full walk-forward
lookback L, the trailing estimation window
cost_model per BL-IS-005, taking envelope parameters as inputs
Raises when:
lookback >= T
a position would open before L observations exist
any parameter is passed as a fitted value rather than a fitting ruleThe last check is the important one. The harness refuses a pre-computed beta. It takes the rule for computing beta and computes it itself, at each bar, from the data it is allowed to see. Accepting a fitted parameter would reintroduce precisely the defect the instrument exists to eliminate.
6. What it is honest about
It does not reproduce live results. It gets the sign right.
On the one strategy in this record measured in all three environments:
| Environment | Result |
|---|---|
| Backtest, full-window fit | +180.0 bps |
| Walk-forward | -55.0 to -68.0 bps |
| Live, 105 trades | -25.5 bps |
The backtest missed live by more than two hundred basis points. The harness missed it by roughly thirty to forty, erring toward pessimism.
That residual is not small and this record does not claim otherwise. What the harness delivers is a number on the correct side of zero, which is the decision the number is used for.
7. A defect found while publishing this instrument
Writing the reference implementation turned up a second defect, unrelated to the look-ahead one and in a different part of the loop.
The sanity checks on the current bar's trailing fit, the beta band and the minimum sigma, sat ahead of the branch that separates an open position from a flat one. On failure they skipped to the next bar.
That ordering is correct while flat. A fit outside the beta band is not tradeable, so there is nothing to do.
It is wrong while a position is open, because none of the exit logic reads the current bar's fit. Exit, stop and timeout are all evaluated against the beta, alpha, mu and sigma frozen at entry, which is the freeze described in section 3. The current fit is computed, recorded, and otherwise unused.
So a single degenerate window on the current bar, most often a stretch of flat prices inside the lookback, would skip that bar's exit evaluation entirely while holding a live position.
for each bar t:
fit the trailing window
if the fit is out of band: <- ran before the position check
skip to the next bar
if flat: consider an entry
else: consider an exit <- never reached on a skipped barThe consequence is a stop or a timeout that can fail to fire. On a constructed series where every window after entry is flat, the position opens and is never evaluated again: the harness returns no closed trade at all, because the exit it was due was skipped on every subsequent bar.
A risk control that can silently not run is a different class of defect from a measurement error. It does not produce a wrong number. It produces no number, and a position that is still open.
In the published implementation the checks sit inside the flat branch, so an open position is evaluated on every bar regardless of what the current, unused, trailing fit looks like. The test that pins it constructs the scenario above and asserts the timeout fires on schedule; under the original ordering that test returns an empty trade list.
No published verdict is affected. The cointegration results this harness produced ran on liquid instruments where a fully flat lookback window does not occur, and the reported figures reproduce unchanged. The defect is latent in the code rather than present in the record, which is the only reason it survived to be found here.
8. What it does not cover
Fill assumptions. The harness simulates at recorded prices and does not model
whether an order would have been filled. For passive strategies that gap is
large, and BL-IS-008 addresses it separately.
Market impact. Nothing in this record ran at a size where its own transacting moved the book.
Selection of the universe, the era, or the rebalance phase. Those are choices
made outside the harness, and a clean walk-forward on a universe selected with
hindsight is still a look-ahead result. BL-IS-004 covers the phase case.
9. Standing status
Declared a permanent validation instrument on 2026-06-25 and mandatory for validating any mean-reversion or momentum strategy thereafter.
Every cross-sectional result in Programme II ran through it or through its
successor construction. No result in this record that was produced without it
carries a RELEASED verdict.
10. Cross-references
BL-IN-003 the incident. BL-D-011 section 3 on the causality constraint.
BL-D-010 section 2.5. BL-D-009 rule R-25. BL-IS-005 the cost model.
Ledger rows COINT, SPR-MOM, XSEC-REV, XSEC-MOM, XSEC-CAR.
Copyright (c) 2026 Bijective Labs. All rights reserved.