如何使用 Aeq x <= beq 中的约束允许权重介于 -1 和 1 之间

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

我正在使用 quadprog 寻找最佳权重的投资组合。

到目前为止,我已经成功实现了 long-onlyshort-only 约束,如下所示:

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

长单

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);

仅做空

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);

我现在正在寻找一种方法将这两者结合起来并允许多头和空头权重,因此 x 可以在 -1 和 1 之间。我该如何实现?

我尝试了以下方法,但它只给我相同的权重:

多空都行(不行)

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和1之间,那么b最后一个分量中的-1也应该是+1。表示 –Σw_i ≤ 1 等同于 –1 ≤ Σw_i。将它与 Σw_i ≤ 1 结合,得到 –1 ≤ Σw_i ≤ 1:

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