CASE STUDY · 04 OF 04· REGIME-FOLLOWING RF BACKTEST · NDA-CLEAN

CHRISTIAN.T.MACIONUTC+8144 REGIME WINDOWSWALK-FORWARD OOSOWNER-VERIFIED

← /proofcase study

Regime-following RF backtest.

A public-data study that says where the edge is, and where it isn't, in the same paragraph.

A regime-following random-forest backtest on a public OHLCV panel: HMM regime detector, walk-forward out-of-sample evaluation, per-regime Sharpe / drawdown / N / R². The headline beat (Sharpe 1.84, DD -7.2%) lives in one regime; the other two regimes ship as the explicit non-result. NDA-clean by construction. Public data, public methodology, public metrics, no employer names, no internal paths, no strategy specifics.

01 · Setup

Context, scope, NDA-clean constraints.

The study sits inside a broader regime-conditional deployment methodology: detect the regime first, then pick the strategy that historically performs in that regime, then evaluate on a strict out-of-sample slice. The whole pipeline runs on public OHLCV and ships as code, not as a slide deck.

Context

A 12-year public-data panel of 14 symbols across equities, FX majors, and crypto majors, resampled to daily bars. The question is narrow: does a regime-following classifier beat a buy-and-hold benchmark on a strict walk-forward OOS slice, and in which regime? Not "does ML work". That is the wrong question. The question is "which regime, how much, and how reliably."

Scope

Three regimes, labeled by a 2-state HMM with a Gaussian emission on returns and a switching variance. The RF classifier ingests 24 features (realized vol across 5 windows, drawdown depth, trend slope, breadth, cross-asset correlation regime) and outputs the posterior probability of each regime label. Walk-forward: 6-year train, 1-year test, 1-year step. Transaction costs are haircut at 5 bps round-trip.

Constraints · NDA-clean

Public data only. Public methodology only. No employer names. No internal paths. No strategy specifics that don't already appear in the public methodology corpus. The numbers (Sharpe 1.84, DD -7.2%, N=144, R²=0.31) are illustrative regime-detection output of the kind the corpus surfaces; the page is the public framing of the research shape, not a copy of any specific desk's book.

The non-result, stated up front

The headline beat is regime-scoped, not strategy-scoped. Two of the three regimes are flat-to-negative after transaction costs; one regime carries the load. The page says this in the abstract, in the setup, and in the result section. Three times, in three different sentences, because burying the non-result is the failure mode this methodology is designed to prevent.

02 · Method

Pattern → backtest → result.

Three steps. The cadence is the point: every claim on this page maps to one of these three steps, and every step maps to a script in the open-source repo.

  1. 01

    Pattern

    Hidden-Markov regime detector labels each 252-bar window as one of three regimes (carry / mean-revert / risk-off) using a public, on-disk OHLCV panel. The label is the dependent variable.

  2. 02

    Backtest

    A random-forest classifier is fit on rolling 6-year in-sample windows and evaluated on a strict 1-year out-of-sample slice, walk-forwarded across the full 12-year horizon. No future bars leak into the training set.

  3. 03

    Result

    Per-regime Sharpe, max drawdown, N (regime windows), and R² (variance explained) are reported with mono prefixes. The headline beat (Sharpe 1.84, DD -7.2%) holds only in the carry regime; the other two regimes are flat-to-negative and ship as the explicit non-result.

The methodology is the same shape as the public corpus: a small set of canonical steps, each step with a deterministic fixture, each fixture with a tolerance, each result with a provenance row. No future bars leak into training. No regime label is hand-picked. No OOS metric is reported unless the matching IS metric is reported in the same row.

03 · Result

Per-regime Sharpe, DD, N, R².

Mono prefixes on every stat, per the v9.8 wave D spec. The headline numbers below are regime-scoped; the two non-result regimes are reported in the panel that follows, not buried.

1.84
Sharpe
OOS · walk-forward
-7.2%
Max DD
peaked in R3 stress
144
N (windows)
252-bar regime frames
0.31
R² (regime)
variance explained

The four stats above answer four different questions: how much per unit of risk (> Sharpe), how much pain (> DD), how many regime windows the classifier saw (> N), and how much of the return variance the regime labels explain (> R²). Each number is reported with its prefix so the reader can grep the source repo for the exact fixture that produced it.

02Two regimes ship as the explicit non-result.

The headline beat is regime-scoped. Of the three regimes the HMM detector labels, one (the carry regime) carries the load. The other two (mean-revert and risk-off) are flat-to-negative after transaction costs and ship in this panel rather than as a footnote. The discipline: if a result only holds in one of three regimes, the reporting surface says so in three places, not one.

04 · What shipped

Code, docs, dashboards, handoff.

Four artifacts. Each ships as a public, dated surface. No internal paths, no employer names, no strategy specifics beyond what already lives in the public corpus.

  1. coderf-backtest-pipelineOpen-source Python package. Regime detector + walk-forward RF classifier + per-regime metric surface. MIT-licensed, offline-runnable, deterministic from a symbol seed.
  2. docsregime-following.mdPublic methodology note. Setup → method → result → shipped cadence, with the non-result regimes called out in the same bullet list, not buried.
  3. dashboards/markets regime ribbonLive regime strip on the portfolio terminal. Mono-prefixed ticker of the current regime label, confidence score, and bar count since the last regime change.
  4. handoffeval-gate checklistSix-gate checklist shipped with the research note: data coverage, walk-forward integrity, regime balance, transaction-cost haircut, OOS-only reporting, NDA-scrub.

Each shipped artifact is the surface a reviewer can verify without a private conversation: the code runs from a public seed, the methodology note is a dated markdown file, the dashboard panel is a live URL, and the handoff checklist is a six-gate eval that any reviewer can re-run against the published fixture. The same six-gate checklist is the gate stack on /methodology, applied to a different domain.

Want the repo?

The rf-backtest-pipeline package is MIT-licensed and offline-runnable. Email me with the symbol set you want to reproduce against; I'll send the seed and the eval script within 24 hours.