Hello,
Could you kindly help me with the following issue: Is there a more efficient way to formulate the problem below?
It involves two for loops and takes about 6h to run in matlab.
lambda = 0.001:0.001:0.02; %pricing error
for j = 1:T-t %rolling window over time
for k = 1:length(lambda) %for each pricing error
cvx_begin quiet
variable weights(N)
minimize( sum_square_pos(data(j:t+j,: ) * weights) * 0.5 */T - sum(weights) + lambda(k)*norm(weights(3:end)) ;
cvx_end
weights_RW(j,k,: ) = weights;
dispersion_RW(j,k) = -cvx_optval;
end
end
So I am basically trying to minimize the variance of a return portfolio (data*weights) over rolling windows of size t+j, for each value of the pricing error lambda, while penalizing some of the weights using an L2 norm.
Thank you!