# How do I find the global minimum variance portfolio?

88 views (last 30 days)
Calum Crichton on 31 Jan 2016
Hi everyone,
Just wondered how you find the GMV portfolio? I have used this code http://www.mathworks.com/matlabcentral/fileexchange/36159-global-minimum-variance-model-and-1-n-model-optimal-asset-allocation but I wondered if there was another way?

Alejandra Pena-Ordieres on 3 Dec 2021
Hi Calum,
I understand that you want to find the minimum variance portfolio. You can do this in two ways.
1) The easiest way is to use the Portfolio object. Assume that you have the mean (mu) and covariance (Sigma) of the returns. Then, you can find the minimum variance portfolio like this:
% Define Portfolio object
p = Portfolio('AssetCovar',Sigma,'AssetMean',mu);
p = setDefaultConstraints(p); % Long-only fully-invested portfolio
% Find minimum variance portfolio
w = p.estimateFrontierLimits('min');
Here ( https://www.mathworks.com/help/finance/when-to-use-portfolio-over-problem-based-framework.html ) you can find a list of the portfolio optimization problems that can be solved using the Portfolio object.
2) The second way is to write an optimization problem and solve it:
% 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;
Hope this helps!
Alejandra