Model the Conditional Value at Risk with an ARCHProcess

The returns of Apple stock from January 2009 to April 2014.

 In[3]:= XDateListPlot[aapl, PlotRange -> All]
 Out[3]=

Split the time series in two parts, and use the first part to find a model.

 In[4]:= XapplFirst = TimeSeriesWindow[aapl, {Automatic, {2011, 12, 31}}]
 Out[4]=
 In[5]:= XapplLast = TimeSeriesWindow[aapl, {{2012, 1, 1}, Automatic}]
 Out[5]=

Fit an ARCHProcess to the first time series.

 In[6]:= Xmodel = TimeSeriesModelFit[applFirst, "ARCH"]
 Out[6]=
 In[7]:= Xeproc = model["BestFit"]
 Out[7]=
 In[8]:= X{\[Kappa], {a, b}} = List @@ eproc
 Out[8]=

Find the conditional value at risk for the second part of the time series with significance level at 95%.

 In[9]:= X\[Alpha] = .05; quantile = Quantile[NormalDistribution[0, 1], 1 - \[Alpha]]; VaR = MovingMap[Sqrt[\[Kappa] + {a, b}.(#^2)] quantile &, applLast, 2]
 Out[9]=

Plot the second time series and its values at risk.

 In[10]:= XDateListPlot[{applLast, VaR}, PlotRange -> All, PlotLegends -> {"returns", "value at risk"}]
 Out[10]=

Mathematica + Mathematica Online

Questions? Comments? Contact a Wolfram expert »