fix: preserve gaps in multi-strategy reports - #561
Open
JohnDReynolds wants to merge 1 commit into
Open
JohnDReynolds wants to merge 1 commit into
JohnDReynolds wants to merge 1 commit into
Conversation
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
Fix report preprocessing so a missing observation in one strategy does not remove or replace valid observations from another strategy.
Previously, report-level row deletion could discard an entire date when any strategy column contained a gap, while zero-filling could treat missing observations as real zero returns. This produced incorrect cumulative returns, volatility, and date metadata in multi-strategy reports.
Behavior
Each strategy is now evaluated from its own observed returns instead of a row-wise intersection of every strategy column.
The change:
match_datesconsistently frombasic()andfull()toplots();Complete-data and single-Series report behavior remains unchanged.
Regression evidence
1%,50%,-2%,3%, and1%. They independently compound to(1.01 × 1.50 × 0.98 × 1.03 × 1.01) − 1 = 0.54453341, displayed as0.54. Accepted report preprocessing instead displayed0.02when Strategy A appeared beside another strategy with gaps. Zero-filling also reduced annualized volatility from the direct result of3.51to3.21, and a leading gap caused the report to show2024-01-01instead of the first observation on2024-01-06.stats.comp()andstats.volatility().match_datessettings, gapped benchmarks, leading/interior/all-strategy gaps, caller-input preservation, report delegation, and structurally parsed HTML output. Full-table comparisons exclude the existing Smart Sharpe and Smart Sortino rows because their metric-specific cross-column behavior is not changed here.Verification
git diff --checkpassed.Scope
Changed files:
quantstats/reports.pytests/test_reports.pytests/test_regressions.pyOut of scope:
stats.ulcer_index()match_dates