Portfolio optimization too slow (Markowitz)
조회 수: 7 (최근 30일)
이전 댓글 표시
Hi guys!
I'working on some portfolio optimizations for my thesis and i have a little problem in the Mean-Variance approach. My work: I have a huge series of weekly returns (and weekly-average-prices), from 2010 to today, of 274 bonds (not all of them are issued in 2010); the idea is to divide this huge period (every 12 weeks) and watch what happened to the portfolio weights (and sigma and mu) accross periods. The division in period is a simple for, and it works for every function that i wrote. The only one approach that i think is not good is the Efficient-Frontier using portfolio object. I structured all the approches in function.
The problem is not that the function doesn't work, but it works too slow: I have a total of 40 iteration and at the 18th pass an eternity of time, then after the 23th I never see anything. The point of my MV optimization is that there are not short selling constraint, sum of weights is 1 and a good diversification, so some constraint in the upper bound.
function [MGV_weights MGV_mu MGV_sigma Weights_Max_Sharpe Max_Sharpe_sigma Max_Sharpe_mu Frontier_Risk Frontier_Ret] =...
get_Efficient_Frontier(Sigma, Tot_Ret, nPort, index3, numAsset);
DisplayFigure = 0; %1 = display, 0 = no display
Total_Return = Tot_Ret(:, :)';
[T N] = size(Tot_Ret);
mu=mean(Tot_Ret,2)';
p = Portfolio('AssetMean', mu, 'AssetCovar', Sigma, 'LowerBound',...
0, 'UpperBound',1*ub, 'Budget', 1);
p.RiskFreeRate= 0;
Weights_Max_Sharpe_temp = estimateMaxSharpeRatio(p);
[Max_Sharpe_sigma, Max_Sharpe_mu] = estimatePortMoments(p, Weights_Max_Sharpe_temp);
sigma = sqrt(diag(p.AssetCovar));
[Weights_Frontier pbuy psell] = estimateFrontier(p,nPort);
[Frontier_Risk Frontier_Ret] = plotFrontier(p, nPort);
%% Uniform the length of outputs - this part is for the allocation in the for iter
MGV_weights_temp = Weights_Frontier(:,1);
[MGV_sigma index] = min(Frontier_Risk); %sqrt(MGV_weights'*p.AssetCovar*MGV_weights)
MGV_mu = min(MGV_weights_temp'*mu');
Weights_Max_Sharpe = zeros(1,numAsset);
Weights_Max_Sharpe([index3])= Weights_Max_Sharpe_temp;
Weights_Max_Sharpe = Weights_Max_Sharpe';
MGV_weights = zeros(1,numAsset);
MGV_weights([index3])= MGV_weights_temp;
MGV_weights = MGV_weights';
end
Sigma=variance covariance matrix; Tot_Ret=matrix of returns; nPort=number of portfolios that I want in the frontier; index3=is an index that catch only the position of the assets that are issued (if you run the code you can delete the row where there is index3), numAsset=is the number of TOTAL bond. ub is a number, for example 10% (not too low because in my iteration function in the beginning i have 17 assets).
My problem is on the functions "estimatePortMoments", "estimateMaxSharpeRatio", "estimateFrontier": it works, but too too slow... Anyone know how to speed up the optimization?
I tried also to use the quadprog function, but results are not as good as using portfolio object.
If I wasn't clear ask me! I know that there aree too many output and some part of the code is not optimal.
Thank you all!
Andrea
댓글 수: 0
답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!