Azzera filtri
Azzera filtri

Simple Constraint Question for Quadprog Problem

2 visualizzazioni (ultimi 30 giorni)
Hi, I am a new Matlab user. In my financial statistics class we are learning to use Matlab by using the programs in our textbook; which are not always correct or entirely useful.
We are using the quadprog command to find the efficient frontier, minimum variance and tangency portfolios --- subject to the constraints of no short selling and that no asset is more than 33% of the total portfolio. In order to fulfill no short sales, we omit A and b {in quadprog(H,f,A,b,Aeq,beq,LB,UB)} and use lower bounds all equal to 0, and no upper bounds.
We use values of x to denote the weights of the portfolio, and my question focuses on these inequality constraints, such that x(i)<=33% for all x(i).
How do I carry out this constraint on the weights of the portfolio? I have done everything else, and I include the present code below, thank you for any help!!! :
"% We need to add the constraint no asset is more than 33% of the portfolio.
bmu = [.1;.04;.07;.11;.05] ;
bOmega = [ .38 .02 .01 0 0 ;
.02 .17 .03 .01 .02 ;
.01 .03 .38 .04 .05 ;
0 .01 .04 .47 .03 ;
0 .02 .05 .03 .26 ] ;
Aeq = [ones(1,length(bmu));bmu'] ;
ngrid = 50 ;
muP = linspace(min(bmu),max(bmu),ngrid) ; % muP grid
rf = .028 ;
sigmaP = muP ; % Set up storage
sigmaP2 = sigmaP ;
omegaP = zeros(5,ngrid) ;
omegaP2 = omegaP ;
for i = 1:ngrid ;
omegaP(:,i) = quadprog(bOmega,zeros(length(bmu),1),[],[],Aeq,[1;muP(i)],zeros(5,1)) ;
sigmaP(i) = sqrt(omegaP(:,i)'*bOmega*omegaP(:,i)) ;
end ;
imin=find(sigmaP==min(sigmaP)) ;
Ieff = (muP >= muP(imin)) ;
sharperatio = (muP-rf) ./ sigmaP ;
Itangency = find(sharperatio == max(sharperatio))
figure(1)
fsize = 14 ;
p = plot(sigmaP(Ieff),muP(Ieff),sigmaP(Itangency),muP(Itangency),'*',sigmaP(imin),muP(imin),'o', ...
0,rf,'x') ;
set(p,'markersize',18)
set(p,'linewidth',2)
xlabel('standard deviation of return','fontsize',fsize) ;
ylabel('expected return','fontsize',fsize) ;
set(gca,'xlim',[0 .6])
set(gca,'fontsize',fsize) ;
line([0 sigmaP(Itangency)],[rf,muP(Itangency)])
% print portbook01.ps -deps ;"

Risposte (1)

Richard Brown
Richard Brown il 23 Apr 2012
As far as I can understand your code, you have a constraint that the sum of x is 1, and hence the required constraint is that for all i, x(i) <= 0.33 . So you just should add an upper bound vector
UB = repmat(0.33, 5, 1);
and add this as a final argument to your call to quadprog.

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