← Charlie Yan

riskkit

2026 — Python · numpy · arch

Repository ↗

The parts open-source risk libraries leave out, made first-class.

VaR and ES, by four methods: delta-gamma-vega parametric with a Cornish-Fisher quantile; historical; Monte Carlo; and filtered-historical with GARCH, all with full revaluation. Stress, and reverse stress.

Backtests whose size and power are measured

Kupiec, Christoffersen independence and conditional coverage, the Basel traffic light, Acerbi-Szekely, and DQ. The size and power of each is computed on a known distribution rather than assumed. The Kupiec rule’s exact size at 250 days is a function, not a constant. The CC and DQ p-values are simulated under their exact null instead of read off a χ² table that is wrong at 250 days.

The one rule

A risk number never travels without its state. An empty book is EMPTY, not OK. A locked market can widen the scenario set and freeze VaR, but can never lower it. A stale quote is marked at its last valid mid, and named as stale.

The screening question the code answers directly: the market is limit-down, the book is empty, VaR says risk fell. What do you do? edge_cases.assess returns LIMIT_DOWN with VaR and ES each at least the last unlocked value.