# Walk Forward Validation

Walk-forward validation framework for trading strategies and ML models with...

- Repository: https://github.com/agiprolabs/claude-trading-skills (507 stars)
- Category: Data and ML
- License: MIT
- Last updated: 2026-09-03
- Runs scripts: yes, review before use

## Install

Claude Code: `npx skills add agiprolabs/claude-trading-skills --skill walk-forward-validation -g -a claude-code -y`
Codex: `npx skills add agiprolabs/claude-trading-skills --skill walk-forward-validation -g -a codex -y`
Cursor: `npx skills add agiprolabs/claude-trading-skills --skill walk-forward-validation -g -a cursor -y`
Gemini CLI: `npx skills add agiprolabs/claude-trading-skills --skill walk-forward-validation -g -a gemini-cli -y`
Claude Code plugin marketplace: `/plugin marketplace add agiprolabs/claude-trading-skills`

## Description

Walk-forward validation framework for trading strategies and ML models with time-series-aware splits, overfit detection, and regime-aware validation

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# Walk-Forward Validation

Walk-forward validation framework for trading strategies and ML models. Standard cross-validation (k-fold, random splits) fails catastrophically for financial time series because it introduces lookahead bias and ignores autocorrelation. This skill covers proper time-series validation techniques including rolling and expanding windows, purged cross-validation, combinatorial purged cross-validation (CPCV), and overfit detection metrics.

## Why Standard Cross-Validation Fails

Standard k-fold CV assumes data points are independent and identically distributed (IID). Financial time series violate both assumptions:

1. **Lookahead bias**, Random splits let the model train on future data and predict past data, artificially inflating performance.
2. **Autocorrelation**, Adjacent observations are correlated. A random split that puts Monday in test and Tuesday in train leaks information.
3. **Regime dependence**, Markets shift between regimes. A model trained on a bull market and tested on a bull market tells you nothing about bear market performance.
4. **Label overlap**, If labels are computed over windows (e.g., 24h forward return), adjacent train/test samples share label computation periods, leaking information.

## Walk-Forward Framework

### Rolling Window (Fixed Train Size)

The train window has a fixed size and slides forward in time. This is preferred when you believe older data is less relevant (common in crypto).

```
Window 1: [===TRAIN===][=TEST=]
Window 2:    [===TRAIN===][=TEST=]
Window 3:       [===TRAIN===][=TEST=]
```

**Parameters:**
- `train_size`: Number of bars/days in the training window
- `test_size`: Number of bars/days in the test window
- `step_size`: How far to advance between folds (often equals `test_size`)

### Expanding Window (Growing Train)

The train window starts at the beginning and expands forward. This uses all available historical data, which helps when data is scarce.

The rest: https://github.com/agiprolabs/claude-trading-skills/blob/HEAD/skills/walk-forward-validation/SKILL.md
