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.
Author
|
Hi @polakowo, friendly ping on this PR as well. This adds expanding window and purging gap support to walk-forward analysis, which is important for preventing data leakage in financial ML. Happy to discuss or make changes. Thanks! |
Owner
|
Thanks for the work on this. WFA and purging are useful, but an API like this needs a deliberate design decision before it becomes part of the library, so I’m closing the PR for now. |
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
Enhancement of PR #850 walk-forward API with production-grade features for quantitative research.
Changes
New Parameters:
expanding=True: Expanding window mode where train window grows from index 0 each foldpurging=N: Exclude last N observations from training metrics to prevent data leakage (Lopez de Prado methodology)Files Changed:
vectorbt/portfolio/base.py: Enhancedwalk_forward()methodtests/test_portfolio_walk_forward.py: 6 new test cases covering all new featuresKey Design Decisions
Purging semantics: The purge gap excludes observations from the training window but the test window still immediately follows the original training window. This prevents overlapping observations from being included in parameter optimization while maximizing out-of-sample data.
Backward compatible: All existing parameters default to previous behavior
Relevance to QD Role
Walk-forward analysis is a core technique in quantitative strategy research. The ability to:
...directly demonstrates the kind of quantitative research tooling expertise needed for QD roles.
Building on PR #850 (@original_author). Related research: rolling window parameter stability in adaptive optimization (e.g., PN-AdaGrad, AdaMWU).