How to allow for weights between -1 and 1 using constraints in Aeq x <= beq

半世苍凉 提交于 2019-12-24 08:57:05

问题


I am using quadprog to find a portfolio of optimal weights.

So far, I have managed to implement long-only and short-only constraints as follows:

FirstDegree             = zeros(NumAssets,1);
SecondDegree            = Covariance;

Long only

Aeq                     = ones(1,NumAssets);
beq                     = 1;
A                       = -eye(NumAssets);
b                       = zeros(NumAssets,1);

x0                      = 1/NumAssets*ones(NumAssets,1);
MinVol_Weights          = quadprog(SecondDegree,FirstDegree,A,b,Aeq,beq,[],[],x0, options);

Short-only

Aeq                     = ones(1,NumAssets);
beq                     = -1;
A                       = eye(NumAssets);
b                       = zeros(NumAssets,1);

x0                      = -1/NumAssets*ones(NumAssets,1);
MinVol_Weights          = quadprog(SecondDegree,FirstDegree,A,b,Aeq,beq,[],[],x0, options);

I am now looking for a way to combine those two and to allow for both long and short weights, thus x can be between -1 and 1. How can I achieve this?

I tried the following, but it only gives me equal weights:

Both long and short (does not work)

A                       = [eye(NumAssets); ones(1, NumAssets); -ones(1, NumAssets)]; 
b                       = [zeros(NumAssets, 1); 1; -1];
Aeq                     = [];
beq                     = [];
lb                      = [];
ub                      = [];

x0                      = 1/NumAssets*ones(NumAssets,1);
MinVol_Weights          = quadprog(SecondDegree,FirstDegree,A,b,Aeq,beq,lb,ub,x0, options);

回答1:


If all you want is that the sum of all weights is between –1 and 1, then the –1 in the last component of b should be a +1 as well. It means –Σw_i ≤ 1 which is the same as –1 ≤ Σw_i. Combining it with Σw_i ≤ 1 you get –1 ≤ Σw_i ≤ 1:

A  = [ ones(1, NumAssets);
      -ones(1, NumAssets)]; 
b  = [1;
      1];
Aeq = [];
beq = [];
lb = [];
ub = [];


来源:https://stackoverflow.com/questions/41862287/how-to-allow-for-weights-between-1-and-1-using-constraints-in-aeq-x-beq

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!