0

我正在努力解决 Solve.QP 以获得最小化跟踪错误的解决方案。我有一个由 6 个资产(asset_a 到asset_f)组成的基准。对于我的投资组合,我有上限和下限(我不能在asset_f 中拥有头寸)。还给出了 cov 矩阵。我想获得 6 种资产的投资组合权重,以最小化跟踪误差与基准(asset_f 中的位置等于零)。

基准:

  1. 资产_a:0.3
  2. 资产_b:0.3
  3. 资产_c:0.1
  4. 资产_d:0.1
  5. 资产_e:0.1
  6. 资产_f:0.1

下限:

  1. 资产_a:0.166
  2. 资产_b:0.133
  3. 资产_c:0.037
  4. 资产_d:0.035
  5. 资产_e:0.039
  6. 资产_f:0

上限:

  1. 资产_a:1
  2. 资产_b:1
  3. 资产_c:1
  4. 资产_d:1
  5. 资产_e:1
  6. 资产_f:0

基准权重和界限:

test.benchmark_weights = c(0.3, 0.3, 0.1, 0.1, 0.1, 0.1)
test.lowerbound = c(0.166, 0.133, 0.037, 0.035, 0.039,0)
test.upperbound = c(1, 1, 1, 1, 1, 0)

cov矩阵(test.Dmat):

test.dmat = matrix(c(0.0119127162,  0.010862842,    0.010266683,    0.0009550136,   0.008242322,    0.00964462, 0.0108628421,   0.010603072,    0.009872992,    0.0011019412,   0.007422522,    0.0092528873,   0.0102666826,   0.009872992,    0.010487808,    0.0012107665,   0.006489204,    0.0096216627,   0.0009550136,   0.001101941,    0.001210766,    0.0115527788,   0.001181745,    0.0008387247,   0.0082423222,   0.007422522,    0.006489204,    0.0011817453,   0.012920482,    0.005973886,    0.00964462, 0.009252887,    0.009621663,    0.0008387247,   0.005973886,    0.0089904809), nrow=6, ncol=6)

dvec (test.dvec):

test.dvec = matrix(c(0, 0,  0,  0,  0,  0), nrow=6, ncol=1)

Amat 约束矩阵(test.Amat):

test.amat = matrix(c(1,1,1,1,1,1, 1,1,1,1,1,0, -1,0,0,0,0,0, 0,-1,0,0,0,0, 0,0,-1,0,0,0, 0,0,0,-1,0,0, 0,0,0,0,-1,0, 0,0,0,0,0,-1, 1,0,0,0,0,0, 0,1,0,0,0,0, 0,0,1,0,0,0, 0,0,0,1,0,0, 0,0,0,0,1,0, 0,0,0,0,0,0, -1,0,0,0,0,0, 0,-1,0,0,0,0, 0,0,-1,0,0,0, 0,0,0,-1,0,0, 0,0,0,0,-1,0, 0,0,0,0,0,0), nrow=6, ncol=20)

bvec (test.bvec)

test.bvec =cbind(0, 1, t(test.benchmark_weights), t(test.lowerbound), -t(test.upperbound)) %>% as.matrix() 

然后运行求解器

solve.QP(as.matrix(test.Dmat), test.dvec, test.Amat, test.bvec)

给我

约束不一致,无解!

4

1 回答 1

1

似乎您的Amatand有问题bvec,即您不必传递前 5 个资产的权重总和等于 1 和 6 个资产的总和等于 1,并且基准权重不是约束,但界限是:

library(quadprog)
N = 6L
test.dvec = rep(0, N)
test.amat = cbind(
    rep(1, N),
    diag(1, N),
    diag(-1, N))
test.bvec = c(1, test.lowerbound, -test.upperbound) 

res = solve.QP(test.dmat, test.dvec, test.amat, test.bvec, meq=1L)
round(res$solution, 2)
#[1] 0.17 0.13 0.10 0.44 0.17 0.00
于 2020-05-19T00:33:39.107 回答