Skip to content

feat(portfolio): add expanding window and purging to walk_forward - #1

Open
caiyi0616 wants to merge 4 commits into
masterfrom
feature/walk-forward-enhanced
Open

feat(portfolio): add expanding window and purging to walk_forward#1
caiyi0616 wants to merge 4 commits into
masterfrom
feature/walk-forward-enhanced

Conversation

@caiyi0616

Copy link
Copy Markdown
Owner

Summary

This PR enhances PR polakowo#850 walk_forward with two critical features for rigorous backtesting:

New Features

1. Expanding Window Mode (expanding=True)
Train window starts at index 0 and grows each fold.

2. Purging Gap (purging=N)
Excludes last N observations from training window to prevent leakage.

3. Summary Statistics Row
Mean/std/min/max of test metrics across folds.

Changes

File Change
vectorbt/portfolio/base.py Enhanced walk_forward()
tests/test_portfolio_walk_forward.py 6 new test cases

Backward Compatibility

All existing parameters work identically.

Sindhu Kothuri and others added 4 commits May 4, 2026 14:49
- Add `expanding=True` mode: train window starts at index 0 and grows
  each fold, allowing comparison between rolling and expanding windows.
- Add `purging` parameter: exclude last `purging` observations from training
  window before computing metrics, preventing leakage from overlapping
  train/test data (Lopez de Prado 2018 methodology).
- Add summary statistics row (mean/std/min/max of test metrics) to the
  result DataFrame for easy aggregation.
- Add 6 new test cases covering expanding window, purging gap enforcement,
  rolling vs expanding comparison, and summary row validation.
- Backward compatible: all existing tests pass with default parameters.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant