How to constrain this optimisation to be long-only?
6 次查看(过去 30 天)
显示 更早的评论
Hi everyone, I'm using a library that optimise a portfolio based in past information and my views on best stocks. However, I need the final weights to be long-only (i.e. positives). Any idea if this is possible? See below the code:
function Allocation = DecisionBayesParameters(Market,InvestorProfile,Prior)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% estimate market parameters
Exp_LinRets_Hat=mean(Market.LinRetsSeries)';
Cov_LinRets_Hat=cov(Market.LinRetsSeries);
T=Market.T;
T_1=Prior.T_0+T;
Exp_LinRets_Post=(Prior.LinRets_EV*Prior.T_0+Exp_LinRets_Hat*T)/T_1;
Nu_1=Prior.Nu_0+T;
Cov_LinRets_Post=(Prior.LinRets_Cov*Prior.Nu_0+Cov_LinRets_Hat*T+(Exp_LinRets_Hat-Prior.LinRets_EV)*(Exp_LinRets_Hat-Prior.LinRets_EV)'*Prior.T_0*T/T_1)/Nu_1;
Exp_Prices_Hat=diag(Market.CurrentPrices)*(1+Exp_LinRets_Post);
Cov_Prices_Hat=diag(Market.CurrentPrices)*Cov_LinRets_Post*diag(Market.CurrentPrices);
% compute allocation
S=inv(Cov_Prices_Hat);
A_Hat=Market.CurrentPrices'*S*Market.CurrentPrices;
B_Hat=Market.CurrentPrices'*S*Exp_Prices_Hat;
Gamma = (InvestorProfile.Budget - InvestorProfile.RiskPropensity*B_Hat)/A_Hat;
Allocation = InvestorProfile.RiskPropensity*S*Exp_Prices_Hat + Gamma*S*Market.CurrentPrices;
This is the library: https://uk.mathworks.com/matlabcentral/fileexchange/9061-risk-and-asset-allocation
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Portfolio Optimization and Asset Allocation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!