0

我用 AAPL 做了这个可重现的例子,但是我正在使用其他数据。但结构完全一样。我正在尝试为我的数据制作与此博客条目类似的报告:

使用 R 和 Knitr 的交易策略绩效报告

我的代码:

require(quantmod)
require(PerformanceAnalytics)
getSymbols("AAPL")
AAPL.DF<-data.frame(Date=index(AAPL), coredata(AAPL[,1]))
AAPL.DF[,2]<-ROC(AAPL.DF[,2])
colnames(AAPL.DF)<-c("Date","rtn")
dailyRtn <- as.numeric(substring(AAPL.DF[,"rtn"],1,nchar(as.character(AAPL.DF[,"rtn"]))-1))
dailyDD <- as.vector(Drawdowns(dailyRtn/100))

最后两行是从这个博客条目中使用的函数复制而来的,我用它来生成 PDF 报告。我真的不明白dailyRtn 的第8 行是做什么的......但真正的问题是关于Drawdowns 函数。总是有一个错误说:

Warning message:
In merge.zoo(fx, .xts(, .index(x))) :
  Index vectors are of different classes: integer POSIXct 

但这在我看来没有任何意义。第 8 行只生成一个 num 系列,没有任何类型的索引。如果我“F2”Drawdowns 函数,我找不到 merge.zoo 的用途。错误在哪里?

4

0 回答 0