在学习用quantstrat做策略回测,在生成signals的时候碰到一个问题:
test<-applySignals(strategy.st,mktdata = HLC(XLB))#报错如下
Error in .xts(e, .index(e1), .indexCLASS = indexClass(e1), .indexFORMAT = indexFormat(e1), :
index length must match number of observations
以上报错来自如下signal的设置:
add.signal(strategy.st, name = "sigThreshold",
arguments = list(column = "cumCRSI.CRSIcum",
threshold = cumThresh,
relationship = "lt",
cross= FALSE),
label="cumCRSI.lt.thresh")
test<-applySignals(strategy.st,mktdata = HLC(XLB))#报错如上
其中cumCRSI.CRSIcum列是在前面的indicator中生成的,已通过applyIndicators验证存在。所以我就不知道问题会出在哪里,还请会用quantstrat的R友指点。