对于每日收益,我有以下 AR(1)-GARCH(1,1) 模型 其中 , , ,和。我需要计算时间多头头寸和空头头寸的 99% 2 天 VaR 和预期缺口。我不知道如何计算这个。有人可以告诉我或至少提供一个有很好例子的参考吗?
使用 AR-GARCH 计算 VaR
机器算法验证
加奇
风险
拱
2022-03-23 13:15:46
1个回答
这最好通过模拟来完成。请参阅下面的我的 MATLAB 代码示例和说明:
%% Get S&P 500 price series
d=fetch(yahoo,'^GSPC','Adj Close','1-jan-2014','30-dec-2014');
n = 1; % # of shares
p = d(end:-1:1,2); % share price, the dates are backwards
PV0 = n*p(end); % portfolio value today
%%
r=price2ret(p,[],'Continuous'); % get the continous compounding returns
Mdl = arima('ARLags',1,'Variance',garch(1,1),'Constant',0);
fit = estimate(Mdl,r) % fit the AR(1)-GARCH(1,1)
fit.Variance
[E0,V0] = infer(fit,r); % get the estimated errors and variances
%% Simulate periods ahead
[Y] = simulate(fit,2,'Y0',r,'E0',E0,'V0',V0, 'NumPaths',1e5);
ret = sum(Y); % compund the return
histfit(PV0*(exp(ret)-1),100,'normal')
title 'P&L distribution'
ret2d = prctile(ret,0.01); % get the 99% lowest return
VaR = PV0*(exp(ret2d)-1);
fprintf('Today portfolio value: %f\n2-days ahead 99%% VaR: %f\n',PV0,VaR);
输出:
ARIMA(1,0,0) Model:
--------------------
Conditional Probability Distribution: Gaussian
Standard t
Parameter Value Error Statistic
----------- ----------- ------------ -----------
Constant 0 Fixed Fixed
AR{1} -0.020272 0.0697731 -0.290541
GARCH(1,1) Conditional Variance Model:
----------------------------------------
Conditional Probability Distribution: Gaussian
Standard t
Parameter Value Error Statistic
----------- ----------- ------------ -----------
Constant 7.43521e-06 2.14546e-06 3.46556
GARCH{1} 0.653488 0.126818 5.15295
ARCH{1} 0.206016 0.0881823 2.33626
fit =
ARIMA(1,0,0) Model:
--------------------
Distribution: Name = 'Gaussian'
P: 1
D: 0
Q: 0
Constant: 0
AR: {-0.020272} at Lags [1]
SAR: {}
MA: {}
SMA: {}
Variance: [GARCH(1,1) Model]
ans =
GARCH(1,1) Conditional Variance Model:
--------------------------------------
Distribution: Name = 'Gaussian'
P: 1
Q: 1
Constant: 7.43521e-06
GARCH: {0.653488} at Lags [1]
ARCH: {0.206016} at Lags [1]
Today portfolio value: 2090.570000
2-days ahead 99% VaR: -79.986280

对于由一股标准普尔 500 指数组成的投资组合,我得到的当前值为2091美元,99% 的 2 天 VaR为 80美元。
我还用正态拟合绘制了损益分布,因此您可以看到正态分布不是一个很好的拟合。这就是为什么在使用 GARCH 时必须进行模拟的原因。
您还可以在此处查看 MATLAB 自己的 GARCH 示例。
这个想法是您将 AR(1)-GARCH(1,1) 拟合到回报中。然后你蒙特卡洛模拟了两天前的回报。然后你在每条路径中复合两天的回报,并找到 0.01 个百分位数。这是在 99% 的回报率信心下你会损失多少或更多,就美元而言,这是使用当前投资组合价值的简单算术。
您可以在本书中找到经过验证的示例:Carol Alexander,市场风险分析,第四卷,风险价值模型,2009 年 2 月