financial portfolio optimization using fmincon?

3 visualizzazioni (ultimi 30 giorni)
Yang
Yang il 16 Nov 2012
Hi y'all. I'm struggling to solve a portfolio optimization problem. I know other ways to do it but I am curious about how to solve it with fmincon. Here is what I've come up with
function[weight,psd,sharpe]= poptim(mu,sigma,mutarget)
function[sigmap] = psigma(weight,sigma)
sigmap = weight.'* sigma *weight ;
end
x0 = [1/3;1/3;1/3];
Aeq = [1 1 1; mu];
beq = [1;mutarget] ;
options=optimset(Algorithm ,'sqp');
[weight,fval]= fmincon(@psigma,x0,[],[],Aeq,beq);
psd = sqrt(fval);
sharpe = (mu * weight)/ psd ;
end
because fmincon requires a function to work with therefore I have to write a function within a function. Problems: the first sigma is unused, making the whole thing stuck
Anyone has any idea how to rearrange them so that it could work?
Thank you!

Risposte (1)

Akiva Gordon
Akiva Gordon il 16 Nov 2012
If you want the sigma passed into POPTIM to be also passed into PSIGMA, you do not need to specify sigma as an input parameter to PSIGMA, since the scope of PSIGMA includes the scope of POPTIM due to the fact that PSIGMA is a nested function of POPTIM.
  3 Commenti
Akiva Gordon
Akiva Gordon il 16 Nov 2012
sigma is an input to POPTIM, isn't it? Perhaps I am not understanding your question...
Yang
Yang il 16 Nov 2012
Nevermind. Thank you for your input!
For later viewers:
If you are trying to solve a Markowitz portfolio optimization problem, use quadprog instead of fmincon!

Accedi per commentare.

Categorie

Scopri di più su Portfolio Optimization and Asset Allocation in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by