Repository navigation
๐ vartests 0.3.0: corrected tests, exact binomial family and modern packaging
โจ What's new
Version 0.3.0 fixes statistical errors in the existing tests, adds exact coverage tests and modernizes the packaging. Coverage tests now work for any quantile-based risk measure (VaR, Drawdown at Risk and others).
๐ฏ New tests
- ๐งฎ
binomial_test: exact binomial test, one- or two-sided (alternative="greater" | "less" | "two-sided") - โ๏ธ
mid_p_test: mid-p correction (Lancaster, 1961), closer to the nominal size - ๐ฒ
poisson_binomial_test: exact test with a different probability of violation per observation - ๐
binomial_power: size and power of the binomial test for a given sample - ๐
garch_pit: PIT of a rolling GARCH(1,1), with no look-ahead, for the Berkowitz test
Exact tests also report the non-rejection region and the effective size.
๐ Fixes
- โ
kupiec_testno longer rejects automatically with zero violations; it now reproduces Table 10.1 of Giambiagi (ch. 10) and returns the p-value - โฑ๏ธ
duration_testfixes the likelihood when the series does not end with a violation (the usual case); p-values change in most samples - ๐ผ
zero_mean_testworks with pandas 2 and 3 and accepts Series - ๐
berkowitz_tail_testnow receives the PIT of the model being tested; GARCH fits are scale-invariant and report convergence failures
โ ๏ธ Breaking changes
- ๐ Result keys are standardized:
statistic,p-value,decision,null hypothesis - ๐ท๏ธ
berkowtiz_tail_test(pnl, ...)is deprecated (still works, with a warning); useberkowitz_tail_test(garch_pit(pnl), ...) - ๐ Requires Python 3.10 or later
๐ฆ Packaging
- Poetry with up-to-date dependencies (numpy, scipy, pandas 2/3, arch 7/8)
- CI on GitHub Actions for Python 3.10, 3.11 and 3.12, with automatic publishing to PyPI
- No more prints or global warning filters on import
๐งช Quality
30 automated tests (94% coverage), including Monte Carlo checks of size and power and comparisons with scipy.stats.binomtest.
๐ฅ Install
pip install -U vartestsFull documentation: see the README.