I seem to have a problem running this with my data, in particular I often get very small numbers in my covariance matrix (sometimes it’s singular) and the efficient frontier doesn’t look right.
If my assets are absolute weekly index prices am I correct in thinking that my expected returns are just the mean relative value of each index? E.g. I have zbar = [1.2; 13.51; 0.06; 0.88; 2.52]. And the covariance matrix is just cov(data) with data being the matrix of absolute prices, with each column being an asset, and each row a week? I’m not sure what I’m doing wrong, any help is appreciated.
]]>Hi Christian,
As long as the horizon (daily, monthly, yearly, etc) is consistent for both the expected return vector and the covariance matrix the program should still work. You should be able to do this with daily returns without any changes, and it should work with decimals returns….again as long as everything is consistent.
The constraints problem is trickier. I don’t know of any non-iterative way to do the constrained optimization…i.e. I don’t think there is an easy modification you can make to the linear algebra equations. Instead I think you need to use some kind of iterative optimization technique.
-Chad
]]>Fantastic article series. As Frontcon (MatLab) is not implemented in Octave, these pages has been great inspiration.
I have two questions. I would like to use this approach for a portfolio optimisation problem. But I need to evaluate on daily returns and stdev over daily returns (and in decimals instead of % – as in 0.10 instead of 10% etc.). I’m not sure how to do this trick. ( like transforming daily Sharpe to yearly with Yearly sharpe = Daily sharpe * sqrt(252)) – 252 trading days.
Also how do you add constraints, eg. no short positions (negative weight). ?
All the best!
Christian
]]>