test: pin estimators to reference values - #559
Open
WatchTree-19 wants to merge 1 commit into
Open
WatchTree-19 wants to merge 1 commit into
WatchTree-19 wants to merge 1 commit into
Conversation
Adds tests/test_reference_values.py, which checks eleven stats functions against the convention each one implements (sample volatility, geometric CAGR, Sharpe, Sortino, drawdown, Calmar, Gaussian VaR and CVaR, Omega, adjusted skewness and excess kurtosis) on five fixed return series, including the 24-month portfolio from Bacon (2008). Eight of the eleven are R PerformanceAnalytics 2.1.0 output; the R call is recorded beside each metric in tests/data/reference_values.json. The other three were checked against numpy, scipy or a brute-force definition. A change to any estimator now fails a named test.
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.
Adds
tests/test_reference_values.py: elevenstatsfunctions checked against the convention each one implements, on five fixed return series (Bacon's 2008 24-month portfolio, a seven-point sample, Gaussian, Student t(3) and left-skewed daily series), 56 cases.Eight of the eleven expected values are R PerformanceAnalytics 2.1.0 output, and the exact R call is recorded beside each metric in
tests/data/reference_values.json(volatility, CAGR, Sharpe, max drawdown, Calmar, Omega, skewness, kurtosis). Sortino and the Gaussian VaR and CVaR, which PerformanceAnalytics computes differently, were checked against numpy, scipy or a brute-force definition. All pass on main today, so this changes no behaviour; it means a future change to an estimator fails a named test instead of shifting numbers silently. Changing the sample volatility, the VaR standard deviation or the skewness estimator by even 1e-6 each fails five cases.Test-only, no new dependencies. The Ulcer index is left out here because it needs #558; it is one entry to add once that lands. Values come from https://github.com/WatchTree-19/vetted.