Skip to content

Rolling Z-score

Rolling z-score (x − rolling_mean) / rolling_std of an upstream series — a mean-reversion building block. A constant window returns 0 rather than NaN. Edge-first. Wired to more than one Price Factor, it fans out to per-ticker by_symbol results.

How to use

  1. Connect an upstream series (price or returns).
  2. Set window (default 20) and ddof (0 = population, 1 = sample).
  3. A large |z| means the series is stretched from its rolling mean.

Core formulas

z_t = (x_t − mean(window_t)) / std(window_t, ddof)
None for the first (window−1) points or any window containing NaN/None
0.0 when std(window_t) < 1e-12 (constant window)

Assumptions & applicability

Assumptions: local stationarity within the window; window ≥ 2.

Applicability: any asset class / frequency; ≥ 2 observations.

Out of scope: whole-history standardization (use the non-rolling z_score), adaptive window.

Known limitations

  1. Constant windows collapse to 0 — guarded against NaN, but carries no signal.
  2. Assumes local stationarity within the window.
  3. First window−1 points are None (warmup).

References

Standard statistical standardization, rolling form (textbook mean-reversion normalization).

Golden Test

tests/golden/fixtures/tier1/compute_zscore/ — 1e-9 absolute, independent pandas-rolling reference, 2026-05-25 passing. Locks the constant-window → 0 guard, warmup None, NaN-in-window → None, and ddof.

Changelog

  • 1.0.0 (2026-05-25) — Promoted Draft → Active; golden added; required fields completed.

Verifiable intelligence for the decisions that demand scrutiny.