Compute the optimal portfolio minimizing the Expected Value (this is a linear programming problem). The Value at Risk of the portfolio is also computed (this implements the Rockafeller-Uryasev algorithm)
[w,ES,VaR]=esvaroptim(price,ER,r,dt,alpha);
Give the historical prices of a set of assets, compute the optimal portfolios solving four different problems. All of them minimize the Expected Shortfall subject to the constraint of having given expected return. The four problems are different for the following characteristics
1) optimal portfolio allowing short selling and investing in the riskless asset;
2) optimal portfolio allowing short selling but without investing in the riskless asset;
3) optimal portfolio not allowing short selling and investing in the riskless asset;
4) optimal portfolio not allowing short selling and without investing in the riskless asset.
Finally the Vale at Risk of the optimal portfolio is computed. The procedure uses "qld" function.
First we generate 1000x3 log-normally distributed daily asset prices with 0.1/250 mean and 0.2/sqrt(250) variance. The first prices of the three assets are 25 euros, 50 euros, and 110 euros respectively.
-->M=grand(1000,3,'nor',0.1/250,0.2/sqrt(250));
-->price=exp(cumsum(M,1))*diag([25 50 110]);
Now we can use the function on these prices.
-->[w,ES,VaR]=esvaroptim(price,0.05,0.01,1/250,0.01)
Draw frontier? (y/n) y
! with short selling without short selling !
! with r without r with r without r !
VaR = 0.0122548 0.0178937 0.0135530 0.0178937
ES = 0.0135257 0.0208130 0.0153525 0.0208130
w = 0.3180045 0.5742962 0.4706583 0.5742962
0.1079194 0.2480433 0.1313949 0.2480433
- 0.1904050 0.1776605 0. 0.1776605
We see that the third asset is sold (negative portfolio component) when it is possible. If short selling is not allowed, then its weight is either positive or zero.
The function also asks if one wants to see the optimal frontiers (this is optional since the procedure takes some time). The figure which is created shows four frontiers corresponding to the four different problems (the legend explains the meanings).
"Optimization of Conditional Value-at-Risk", Rockafeller, R. T. and Uryasev, S., Journal of Risk, 2, 21-41, 2000
Francesco Menoncin - Brescia University - 2010