FerroRisk · reference

VaR and Expected Shortfall

Reference for the portfolio-level Value-at-Risk and Expected Shortfall estimators in ferro-risk.

ferro-risk ships three families of Value-at-Risk estimators. All three share the same trait surface so they can be swapped in a portfolio config without touching call sites.

Historical VaR

The empirical quantile of a P&L sample. Robust to fat tails because it makes no distributional assumption, but slow to react to regime changes because every observation is weighted equally.

Inputs

  • A sorted slice of historical P&L observations.
  • A confidence level α(0,1)\alpha \in (0, 1), typically 0.99.

Output

The negative of the α\alpha-quantile of the P&L distribution, returned as a positive number representing a loss.

Parametric VaR

Assumes Gaussian P&L with mean μ\mu and standard deviation σ\sigma. The α\alpha-VaR is then

VaRα=μσΦ1(1α)\mathrm{VaR}_\alpha = -\mu - \sigma\,\Phi^{-1}(1 - \alpha)

Fast and analytically tractable, but understates tail risk on real return distributions.

Monte Carlo VaR

Simulate NN P&L paths from a calibrated model and take the empirical α\alpha-quantile. Slower than parametric but lets you plug in arbitrary distributions, jumps, or copulas.

Expected Shortfall

For any of the three estimators, expected_shortfall(samples, alpha) returns the conditional mean loss beyond the VaR threshold — the coherent risk measure preferred by regulators.