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 , typically
0.99.
Output
The negative of the -quantile of the P&L distribution, returned as a positive number representing a loss.
Parametric VaR
Assumes Gaussian P&L with mean and standard deviation . The -VaR is then
Fast and analytically tractable, but understates tail risk on real return distributions.
Monte Carlo VaR
Simulate P&L paths from a calibrated model and take the empirical -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.