如何使用Aeq x< = beq中的约束来允许权重在-1和1之间 [英] How to allow for weights between -1 and 1 using constraints in Aeq x <= beq

查看:132
本文介绍了如何使用Aeq x< = beq中的约束来允许权重在-1和1之间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 quadprog 来找到最佳权重的组合

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

到目前为止,我已经设法实现了 long-only only-short 约束,如下所示:

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

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之间.我该如何实现?

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:

长短(无效)

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 :

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 = [];

这篇关于如何使用Aeq x< = beq中的约束来允许权重在-1和1之间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆