极端风险管理关注的是概率极低但影响极大的事件(肥尾、黑天鹅)。传统 VaR 假设正态分布时会严重低估这类风险。
金融收益率通常服从幂律尾部(Pareto distribution):
其中尾部指数 通常在 2~5 之间(正态分布 )。
对超过阈值的超额损失建模:
其中 为形状参数, 为尺度参数。 表示厚尾。
import numpy as np
from scipy import stats
def gpd_fitting(returns, threshold=0.95):
"""超额损失拟合 GPD"""
excesses = returns[returns < -threshold] - (-threshold)
# MLE 估计 GPD 参数
def neg_log_likelihood(params):
mu, sigma, xi = params
if sigma <= 0 or (1 + xi * excesses / sigma) <= 0:
return np.inf
ll = -np.sum(np.log(1/sigma) * (1 + xi * excesses / sigma)**(-1/xi - 1))
return ll
from scipy.optimize import minimize
result = minimize(neg_log_likelihood, x0=[0, 0.05, 0.3],
bounds=[(None, None), (1e-6, None), (-0.5, 0.5)])
mu_hat, sigma_hat, xi_hat = result.x
# VaR 估计
def gpd_var(prob):
if xi_hat != 0:
return -mu_hat + (sigma_hat/xi_hat) * ((prob / n_excess)**(-xi_hat) - 1)
else:
return -mu_hat + sigma_hat * np.log(prob / n_excess)
return {
'mu': mu_hat, 'sigma': sigma_hat, 'xi': xi_hat,
'VaR_99': gpd_var(0.01),
'CVaR_99': gpd_var(0.005),
}
# 峰值过阈 (Peaks Over Threshold)
def POT_analysis(returns, percentile=90):
"""POT 分析"""
threshold = np.percentile(returns, percentile)
excesses = returns[returns < -threshold] + threshold # 负值表示超额损失
return excesses
Adrian & Brunnermeier (2016) 定义 CoVaR 为:当某机构陷入困境时,整个金融系统的 VaR。
def delta_covar(X_system, X_institution, alpha=0.05):
"""计算单个机构对系统性风险的边际贡献"""
# 排序 institutional returns
sorted_idx = np.argsort(X_institution)
# CoVaR when institution is at VaR quantile
var_idx = int(alpha * len(X_institution))
co_var_at_crash = np.percentile(X_system[sorted_idx[:var_idx]], alpha)
# CoVaR at median institutional performance
co_var_at_median = np.percentile(X_system, alpha)
return co_var_at_crash - co_var_at_median
| 场景 | 条件 | 预期损失 |
|---|---|---|
| 基准 | 历史统计波动率正常 | VaR_95 水平 |
| 轻度压力 | 波动率翻倍 | 2x VaR_95 |
| 中度压力 | 波动率翻3倍 + 相关性趋近1 | 5x VaR_95 |
| 极端压力 | GFC/2020 级别 + 流动性枯竭 | 10x+ VaR_95 |
def stress_test(portfolio, scenarios):
"""多维度压力测试"""
results = {}
for name, params in scenarios.items():
# 冲击因子
price_shock = params.get('price_shock', 0)
vol_multiplier = params.get('vol_multiplier', 1)
corr_shift = params.get('corr_shift', 0)
# 计算冲击后组合价值
stressed_returns = portfolio.returns * price_shock + \
np.random.randn(*portfolio.returns.shape) * vol_multiplier
results[name] = {
'pnl': stressed_returns.sum(),
'var_95': -np.percentile(stressed_returns.sum(axis=1), 5),
'max_drawdown': max_drawdown(stressed_returns.cumsum()),
}
return results
| 版本 | 描述 |
|---|---|
| GPD-POT | 极值理论 + 峰值过阈 |
| Extreme Value Theory (EVT) | 极值理论完整框架 |
| CoVaR | 条件 VaR,系统性风险度量 |
| CoVaR | 边际系统性风险贡献 |
| Stress Testing | 情景分析,非概率框架 |