Skip to main content

rustyqlib/risk/
mod.rs

1//! Risk analytics: Value-at-Risk, Expected Shortfall and the
2//! surrounding toolkit, one concern per file.
3//!
4//! - [`measures`]: VaR and ES — historical (empirical quantile / tail
5//!   mean), parametric normal, Cornish-Fisher higher-moment corrected,
6//!   and delta-normal multi-asset VaR with the exact Euler
7//!   component/marginal decomposition;
8//! - [`portfolio_risk`]: scenario VaR/ES for an options book
9//!   ([`EquityPortfolio`](crate::equity::portfolio::EquityPortfolio)) —
10//!   **delta-gamma-vega-theta** from the aggregated Greeks and **full
11//!   revaluation** through the book's repricer, on shared spot/vol
12//!   scenarios so their difference isolates the Taylor error;
13//! - [`volatility`]: realized and EWMA (RiskMetrics) estimators;
14//! - [`performance`]: max drawdown, Sharpe and Sortino ratios;
15//! - [`backtest`]: the Kupiec proportion-of-failures VaR backtest;
16//! - [`stress`]: TOML-configured **stress MtM** — named shock scenarios
17//!   (relative/absolute, per-underlying) bumped into the market data and
18//!   fully revalued, reported per trade and aggregated per scenario;
19//! - [`ladder`]: **risk ladders** — full revaluation on a grid of
20//!   relative spot moves (ladder delta/gamma) or parallel vol shifts
21//!   (ladder vega/volga) read off adjacent rungs: the non-local risk
22//!   view for barrier-heavy books.
23//!
24//! Conventions: confidence levels are one-sided (0.99), VaR/ES are
25//! positive loss amounts, and every simulation is deterministic per
26//! seed.
27
28pub mod backtest;
29pub mod ladder;
30pub mod stress;
31pub mod measures;
32pub mod performance;
33pub mod portfolio_risk;
34pub mod volatility;
35
36pub use backtest::{kupiec_pof, KupiecTest};
37pub use ladder::{
38    spot_ladder, symmetric_moves, vol_ladder, LadderPoint, SpotLadder, VolLadder, VolLadderPoint,
39};
40pub use measures::{
41    cornish_fisher_var, delta_normal_var, historical_expected_shortfall, historical_var,
42    parametric_expected_shortfall, parametric_var, DeltaNormalVar,
43};
44pub use performance::{max_drawdown, sharpe_ratio, sortino_ratio};
45pub use portfolio_risk::{delta_gamma_var, full_revaluation_var, PortfolioRisk, RiskConfig};
46pub use stress::{
47    stress_mtm, ArbitrageCheck, ArbitragePolicy, BumpMode, RiskFactor, ScenarioResult, Shock,
48    StressConfig, StressScenario, TradeStress,
49};
50pub use volatility::{ewma_volatility, realized_volatility};