Risk Metrics

Systemic risk metrics: CoVaR, ΔCoVaR, MES, SRISK.

These implement the standard tail-risk measures used as benchmarks against the Spectral Coarse-Graining (SCG) risk indicator.

References

  • Adrian & Brunnermeier (2016) — CoVaR

  • Acharya et al. (2017) — MES / SRISK

scr_financial.risk.metrics.compute_var(returns, alpha=0.05)[source]

Value-at-Risk at level alpha (left tail).

Parameters:
Return type:

float

scr_financial.risk.metrics.compute_covar(bank_returns, system_returns, alpha=0.05)[source]

CoVaR: VaR of a bank conditional on the system being at its VaR.

Uses the historical simulation approach: subset bank returns to periods where system return <= system VaR, then take the alpha-quantile.

Parameters:
Return type:

float

scr_financial.risk.metrics.compute_delta_covar(bank_returns, system_returns, alpha=0.05)[source]

ΔCoVaR: difference between CoVaR under stress and CoVaR at median.

Positive ΔCoVaR means the bank contributes more risk when the system is stressed.

Parameters:
Return type:

float

scr_financial.risk.metrics.compute_mes(bank_returns, system_returns, alpha=0.05)[source]

Marginal Expected Shortfall: E[r_bank | r_system < VaR_alpha(system)].

Measures a bank’s expected loss conditional on a systemic tail event.

Parameters:
Return type:

float

scr_financial.risk.metrics.compute_srisk(mes, equity, liabilities, k=0.08)[source]

SRISK: expected capital shortfall of a bank in a systemic crisis.

SRISK = max(0, k*(equity + liabilities) - equity*(1 + MES)) where k is the prudential capital ratio (default 8%).

Parameters:
Return type:

float

scr_financial.risk.metrics.compute_system_risk_metrics(bank_returns_dict, alpha=0.05)[source]

Compute all risk metrics for a set of banks.

Parameters:
  • bank_returns_dict (dict) – Maps bank_id → array of returns.

  • alpha (float) – Tail probability.

Return type:

dict mapping bank_id → {var, covar, delta_covar, mes}

Backtesting Engine

Rolling backtesting engine for SCG vs traditional risk metrics.

Loads historical EBA snapshots, builds networks per quarter, computes SCG metrics alongside CoVaR/MES/Basel, and evaluates which model best predicts future bank distress.

class scr_financial.backtesting.engine.BacktestEngine[source]

Bases: object

Rolling backtest comparing SCG, CoVaR, MES, and Basel risk indicators.

load_snapshots(start_year=2020, end_year=2024)[source]

Load quarterly EBA snapshots via the data loader.

Returns the number of snapshots loaded.

Parameters:
  • start_year (int)

  • end_year (int)

Return type:

int

run_rolling(window_quarters=4, step=1)[source]

Run a rolling backtest across loaded snapshots.

For each window, computes risk metrics at time t and checks whether stress materialised at t+step.

Returns a DataFrame with per-quarter metrics.

Parameters:
  • window_quarters (int)

  • step (int)

Return type:

DataFrame

evaluate()[source]

Evaluate predictive accuracy of each risk model.

Returns a dict per model with correlation to future stress, and hit rate (did high risk precede stress increase?).

Return type:

Dict[str, Dict[str, float]]

to_dataframe()[source]

Export results as a DataFrame.

Return type:

DataFrame