Skip to content

๐Ÿš€ vartests 0.3.0: corrected tests, exact binomial family and modern packaging

Choose a tag to compare

@rafa-rod rafa-rod released this 03 Oct 03:09
· 3 commits to main since this release

โœจ 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_test no longer rejects automatically with zero violations; it now reproduces Table 10.1 of Giambiagi (ch. 10) and returns the p-value
  • โฑ๏ธ duration_test fixes the likelihood when the series does not end with a violation (the usual case); p-values change in most samples
  • ๐Ÿผ zero_mean_test works with pandas 2 and 3 and accepts Series
  • ๐Ÿ“ berkowitz_tail_test now 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); use berkowitz_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 vartests

Full documentation: see the README.