<< irs Financial module mef >>

Financial module >> Financial module > markowitz

markowitz

Compute the optimal portfolio minimizing the variance (this is a quadratic programming problem). The optimal variance is also computed.

SYNOPSIS

[portf,varoptim]=markowitz(price,ER,r,dt);

Description

Give the historical prices of a set of assets, compute the optimal portfolios solving four different problems. All of them minimize the Variance of the portfolio 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 Variance of the optimal portfolio is computed. The procedure uses "qld" function.

Parameters

price
matrix whose columns contains the historical prices of the assets in the portfolio
ER
expected return that the investor wants to obtain on his portfolio
r
riskless interest rate
dt
time frequency of the prices with respect to the time unit of measure of both "ER" and "r"; if the matrix of prices contains daily data and both "ER" and "r" are annual return, then dt=1/250 since there are 250 working day in one year

Output

portf
matrix containing the optimal portfolios; in particular:
first raw: with short selling and with r
second raw: with short selling and without r
third raw: without short selling and with r
fourth raw: without short selling and without r
varoptim
Variance of the optimal portfolio

Example

First we generate 100x3 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(100,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.

-->[portf,varoptim]=markowitz(price,0.05,0.01,1/250)

Draw frontiers? (y/n) y

! with short selling without short selling !

! with r without r with r without r !

varoptim =

0.0001508 0.0232294 0.0001508 0.0249650

portf =

- 0.0009446 0.6612090 - 1.444D-34 0.7614173

0.0599034 - 0.0729724 0.0599186 0.

0.0157164 0.4117634 0.0157684 0.2385827

We see that the third or the second asset are 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).

Authors

Francesco Menoncin - Brescia University - 2010

See Also


<< irs Financial module mef >>