Portfolio Optimization Combination problem
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi,
I would like to know if someone knows how to create from n asset al the possible combinations, I'll explain myself: I have 30 asset (AA,...,KO,MCD...) and I want to create all the possible combination of portfolio:
I want portfolio1 with only AA, portfolio2 with only AXG.....portfolio with only KO....
Then I want all the portfolio with 2 asset, so : P1=AA-KO , P2=AA-MCD , ..... Pn=KO-MCD
Then with three asset : P=AA-AXG-KO , P=AA-AXG-MCD , ......, P= AXG-KO-MCD
and so on until I have the portfolio with all 30 asset.
Of course then I want to calculate mean and variance of every portfolio and have displayed for example the one with the max mean and know exactly which asset are in.
I have menaged to write this code but is not exactly what I want and I cannnot solve my problem!
T = readtable('dowPortfolio.xlsx');
tab = T(:,3:end);
nomi = tab.Properties.VariableNames';
P = table2array(tab);
DR = tick2ret(P);
%%
Date = table2array(T(:,1));
mu = mean(DR);
ro = cov(DR);
h = [1:size(tab,2)];
valueOfMu = zeros(1,length(h));
valueOfVar = zeros(1,length(h));
for h = [1:size(tab,2)]
t = DR(:,1:h);
for n = h
noa = nomi(1:n);
end
p = Portfolio('AssetList',noa);
p = estimateAssetMoments(p,t);
NAA = h;
EW = 1/NAA;
p = setDefaultConstraints(p);
p = setInitPort(p,EW,NAA);
wgt = p.InitPort;
[ersk,eret] = estimatePortMoments(p,p.InitPort);
pwgt = estimateFrontier(p);
valueOfMu(h) = eret;
valueOfVar(h) = ersk;
end
%%
VOS = valueOfMu./valueOfVar;
find(valueOfMu==max(valueOfMu))
find(valueOfVar==min(valueOfVar))
find(VOS==max(VOS))
In my code I menage to have some combinantion in particular I start with a portfolio with the singular asset (the first AA) and then the code add at every cycle one asset in order like in tabele T. Then I menage to calculate the mean and the variance but is not an optimal solution because it can not disply the name of the asset in portfolio. So I have to use the find function to find out the index of my max-mean-portfolio and because of the constraction of the code I can understand which asset are in it. But as I wrote I want all the different combinetions and not only the one with the code!
I had an idea of permuting just the asset in the table T and run the code again but I cannot find the way also for this one.
Thanks in advance to everyone.
0 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Portfolio Optimization and Asset Allocation dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!