feat(quantitative): deflated Sharpe ratio command - #7633
Open
ipezygj wants to merge 1 commit into
Open
Conversation
Adds obb.quantitative.performance.deflated_sharpe_ratio (Bailey & Lopez de Prado, 2014): the probability that a strategy's true Sharpe exceeds the expected maximum Sharpe of N zero-skill trials, answering whether a result selected as the best of N tested variants reflects skill or selection luck. Adjusts for sample length and return skewness/kurtosis. - helpers.deflated_sharpe_stats(): pure computation, parity-tested at 1e-7 against the numguard reference implementation - DeflatedSharpeModel + POST command in the performance router, following the omega_ratio pattern - trials_sr_std defaults to the null 1/sqrt(n-1); callers who track their optimizer's actual cross-trial Sharpe dispersion can pass it
|
|
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.
Why
obb.quantitative.performanceships Sharpe, Sortino and Omega — but no way to answer the question that decides whether any of them mean anything after optimization: was this result selected as the best of N attempts, and does it survive that selection? Under pure noise, the expected maximum Sharpe of N zero-skill strategies grows with N; a raw Sharpe from a parameter sweep is a best-of-N number.What
obb.quantitative.performance.deflated_sharpe_ratio(data=returns, target="close", trials=100)— the Deflated Sharpe Ratio (Bailey & López de Prado, 2014): the probability that the true Sharpe exceeds the expected maximum oftrialszero-skill attempts, adjusting for sample length and return skewness/kurtosis. Returns Sharpe, the expected-max bar, the DSR probability, observations and trials.helpers.deflated_sharpe_stats()holds the pure computation; the router command follows the existingomega_ratiopattern (POST,DeflatedSharpeModel, lazy imports, PythonEx/APIEx examples).trials_sr_std(cross-trial Sharpe dispersion) defaults to the null1/sqrt(n-1); callers who track their optimizer's actual trial spread can pass it through the helper.Tests
extensions/quantitative/tests/test_deflated_sharpe.py: parity at 1e-7 against the numguard reference implementation on a deterministic series, single-trial-reduces-to-PSR, monotonicity in trial count, input guards. 5/5 passing locally alongside the existing helper tests.The same math was merged into ffn last week (pmorissette/ffn#311), and equivalents are under review in backtesting.py (kernc/backtesting.py#1388) and jesse (jesse-ai/jesse#611).
Note: I haven't regenerated the static package reference in this PR — happy to run the build step and push it if you'd like it included, or leave it to your release tooling, whichever matches your process.