I am trying to code the risk parity algo from the following Python notebook to MATLAB
I am getting Error(1311): Tyring to append a too big cone.
I am not sure if I define the cones properly. Can you take a look at my code below and tell me what I am doing wrong?
function wgts = erc(n,GT,c,b)
name = 'symbcon';
[~,~, res] = evalc('mosekopt(name)');
prob = [];
% Objective vector: r-c*b'*t (x,t,r)
prob.c = [zeros(n,1);-c*b;1];
% budget constraint
prob.a = [ones(1,n),zeros(1,n+1)];
prob.blc = 0;
prob.buc = inf;
% Bounds exclude shortselling (x,t,r)
prob.blx = zeros(2*n+1,1);
prob.bux = inf.*ones(2*n+1,1)];
% An affine conic constraint: [1, r, GT*x] in rotated quadratic cone
% [ 0 0 0] [ x ] [ 1 ]
% [ 0 0 1] [ ] + [ 0 ] \in Q_r
% [ GT 0 0] [ r ] [ 0 ]
prob.f = sparse( [ zeros(1,2*n+1); [zeros(1,2*n),1]; [GT, zeros(n,n+1)] ]);
prob.g = [ 1; 0; zeros(n,1) ];
prob.cones = [ res.symbcon.MSK_CT_RQUAD n ];
% Logarithmic bounds (xi,1,ti)∈Kexp
% (1,r,Fx)
% [ 0 0 0] [ x ] [ 1 ]
% [ 0 0 1] [ ] + [ 0 ] \in Q_r
% [ GT 0 0] [ r ] [ 0 ]
prob.f = [prob.f; sparse( [ [ones(1,n),zeros(1,n+1)]; zeros(1,2*n+1); [zeros(1,n),ones(1,n),0] ]) ];
prob.g = [prob.g; [ 0; 1; 0] ];
prob.cones = [ prob.cones repmat([res.symbcon.MSK_CT_PEXP 3], 1, n)];
% Maximize problem and return the objective value
[rcode,res] = mosekopt('minimize echo(0)', prob, []);
wgts = res.sol.itr.xx;
end