Compute three risk measures on historical prices of a set of assets, and at a given confidence level. The three risk measures are: Expected Shortfall (ES), Value at Risk (VaR) and a Linear Spectral risk measure (lin).
[ES,VaR,L]=esvarlin(prices,alpha);
On historical prices of some assets compute three risk measures at a given confidence level. The three measures are: Expected Shortfall (the mean of the losses exceeding a given quantile), Value at Risk (coinciding with a quantile), and a Linear Spectral risk measure whose spectrum linearly decreases for losses exceeding a given quantile (the same used for the previous risk measures)
First we generate 1000 log-normally distributed prices for three different assets whose initial values are 25 euros, 50 euros, and 110 euros. First step is the creation of a 1000x3 matrix of normal random variables (with mean 0.1/250 and standard deviation 0.2/sqrt(250))
-->M=grand(1000,3,'nor',0.1/250,0.2/sqrt(250));
Then we create the prices
-->prices=exp(cumsum(M,1))*diag([25 50 110]);
Now the three risk measures are computed
-->[ES,VaR,L]=esvarlin(prices,0.01)
L = 0.0365767 0.0327525 0.0351212
VaR = 0.0274819 0.0281535 0.0281464
ES = 0.0331532 0.0309606 0.0323584
Francesco Menoncin - Brescia University - 2010