# Backtesting with a causality check

The check truncates the data, reruns the graph and compares past outputs. A method whose past changes is refused by name. Machine-learning runs use anchored walk-forward splits with an embargo.

## Truncate the series, replay, compare bar by bar

Your bars are cut at a point in the past. The graph runs again on the shorter series. The contract requires the per-bar P&L on the overlap before the cut to be equal to within 1e-12.

```
cut 0.66 of the series
margin removed from the overlap
compare per-bar P&L, tolerance 1e-12
verdict refusal with the culprit named
replay kernel alone, filters removed
mono one instrument, longest series
```

When filters are wired, the kernel is probed a second time on its own. The message then separates a leaking strategy from a leaking filter, and states which of the two it has.

A third probe replays the graph on a single instrument. When the leak fails to reproduce there, the message names two possible causes without choosing: a cross-sectional kernel, or the portfolio aggregation itself. That case is measured, not hypothetical: an instrument that had not traded yet made the portfolio divisor depend on the future while the symbols were bit-identical.

## A second validation replays the test with zero margin

The production gate allows a boundary margin, and the backend declares its own: 7 days for the engine backend, the label horizon plus the embargo for the machine-learning one, and a fallback read from the holding parameters otherwise.

A backend holding a position across the cut differs on the bars straddling it, for reasons unrelated to look-ahead.

A dependency confined to that window would pass. A second validation replays the same test with zero bars of margin.

## Check the past against a truncated run

The causality check compares the full run with a run cut before the end of the same input. A change before the cut can reveal dependence on future observations. A deliberately leaking control must fail, while a causal control must preserve its earlier values.

The [causality reference](https://stochastly.com/research/causality) shows these controls in the current workspace, with their measured scope and boundary limitations.

## Walk-forward fitting with purge and embargo

Anchored walk-forward splits, purged folds, and an embargo equal to the label horizon. A shuffled K-fold mixes future bars into training on a time series, so the split stays anchored in time.

The proof

A deliberately leaky model, fitted on the full series, is included in release validation. The validation fails unless the gate rejects it.

Scope

### The learning panel ranks the configurations of your own run.

Scope: Your parameter space, on the symbols and the window you loaded.
Effect: A configuration outside that space stays out of the ranking.
Control: Widen the sweep and run it again; the panel re-ranks the new space.

24

machine-learning nodes validated by executable checks

Measured: 2026-09-16

[Screenshot: Walk-forward ribbon in Stochastly, Full desk · 155 nodes, light theme.](https://stochastly.com/screenshots-current/product-backtesting--walk-forward-ribbon--desk.png)

Training and test windows across the walk-forward schedule; colour reports the test result.

## Two diagnostics a reviewer opens first

An equity curve reports what happened over the sample. These two report whether the assumptions under it hold on your own series.

ACF / PACF. The partial version strips the intermediate lags. A lag outside the ±1.96/√N bands marks serial structure, which is the structure a momentum or mean-reversion rule trades.

GARCH(1,1). Volatility clusters, so a constant-sigma sizing rule takes its largest position during the calm before a shock. The fit is checked for stationarity before the panel reports it.

[Screenshot: Equity curve in Stochastly, Full desk · 155 nodes, light theme.](https://stochastly.com/screenshots-current/product-backtesting--equity-curve--desk.png)

Equity across the tested configurations, with the leading curve, cumulative P&L and drawdown visible.

[Screenshot: Rolling Sharpe in Stochastly, Full desk · 155 nodes, light theme.](https://stochastly.com/screenshots-current/product-backtesting--rolling-sharpe--desk.png)

Rolling Sharpe and Sortino estimates over the same recorded return series.

[Screenshot: Worst drawdowns & recovery in Stochastly, Full desk · 155 nodes, light theme.](https://stochastly.com/screenshots-current/product-backtesting--worst-drawdowns-recovery--desk.png)

The deepest drawdowns and the time taken to recover, marked on the strategy equity.

---
Source: https://stochastly.com/product/backtesting
