我正在努力解决 Solve.QP 以获得最小化跟踪错误的解决方案。我有一个由 6 个资产(asset_a 到asset_f)组成的基准。对于我的投资组合,我有上限和下限(我不能在asset_f 中拥有头寸)。还给出了 cov 矩阵。我想获得 6 种资产的投资组合权重,以最小化跟踪误差与基准(asset_f 中的位置等于零)。
基准:
- 资产_a:0.3
- 资产_b:0.3
- 资产_c:0.1
- 资产_d:0.1
- 资产_e:0.1
- 资产_f:0.1
下限:
- 资产_a:0.166
- 资产_b:0.133
- 资产_c:0.037
- 资产_d:0.035
- 资产_e:0.039
- 资产_f:0
上限:
- 资产_a:1
- 资产_b:1
- 资产_c:1
- 资产_d:1
- 资产_e:1
- 资产_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)
给我
约束不一致,无解!