How to calculate minimum variance portfolio with constraints?

15 次查看(过去 30 天)
Dear everyone,
I would like to calculate the weights of a minimum variance portfolio with leverage and short sale constraints. I have found the code below, which winsorizes the weights to 1, namely there the investor cannot leverage her wealth. However, I need to adjust it, so that the investor can leverage up to 2 times her portfolio and short sale up to 1 time her portfolio, in other word the weights (denoted as w) should follow the rule -1<=w<=2 .
% Portfolio problem
prob = optimproblem('ObjectiveSense','minimize');
% Variables
% Portfolio weights
x = optimvar('x',nAssets,1,'LowerBound',0); % x >= 0 (long-only portfolio)
% Objective
% min x'*Sigma*x (Variance)
prob.Objective = x'*Sigma*x;
% Constraints
% Sum of weights equal to 1 (fully-invested)
prob.Constraints.sumToTau = sum(x) == 1;
% Solve problem
sol = solve(prob);
w = sol.x;
  1 个评论
Sargondjani
Sargondjani 2023-2-7
I dont know how you modelled borrowing. Is it simply modelled as a risk free asset?
Anyway, you would have to set the lower bound for that specific asset to -2*Value of portfolio. Then you need to set the lower bound for the sum weights of all other asset to -1 (ie. you can short the risky portfolio once).

请先登录,再进行评论。

回答(1 个)

Alejandra Pena-Ordieres
编辑:Alejandra Pena-Ordieres 2024-9-3
Hello,
If you want to use a risk-free asset to leverage the portfolio, you can use the Portfolio object in MATLAB to achieve what you want by following this example Leverage in Portfolio Optimization with a Risk-Free Asset. In your case, to leverage up to the full value of your portfolio, you'd need to set your upper budget to 2.
% Leverage lower and upper bound
leverageLB = 0; % No leverage
leverageUB = 1; % Up to 100% leverage
p = setBudget(p,1+leverageLB,1+leverageUB);
Using the problem-based formulation that you show in your question, you'd need to modify the costraints of the optimization problem as follows
% Constraints
% No risk-free asset allocation allowed.
prob.Constraints.NoRiskFreeAllocation = sum(x) >= 1+leverageLB;
% Allow up to 100% leverage
prob.Constraints.LeverageUpperBound = sum(x) <= 1+leverageUB;
If you want to allow a positive allocation of the risk-free asset, you'd have to decrese the lower budget to a value less than 1.
If you want to short-sell assets to leverage the portfolio, you'd need to use the setBounds method of the Portfolio object
% Allow assets to short-sell
p = setBounds(p,-1,2);
% Fully-invested portfolio
p = setBudget(1,1);
Using the problem-based formulation, you'd need to modify the lower and upper bounds of the variables
% Variables
% Portfolio weights
x = optimvar('x',nAssets,1,'LowerBound',-1,'UpperBound',2);

类别

Help CenterFile Exchange 中查找有关 Portfolio Optimization and Asset Allocation 的更多信息

产品


版本

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by