feat(portfolio): add expanding window and purging to walk_forward - #1
Open
caiyi0616 wants to merge 4 commits into
Open
feat(portfolio): add expanding window and purging to walk_forward#1caiyi0616 wants to merge 4 commits into
caiyi0616 wants to merge 4 commits into
Conversation
- 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Backward Compatibility
All existing parameters work identically.