我收到“找不到回撤函数”错误。我已经加载了 PerformanceAnalytics 库。
代码:
install.packages("quantmod")
install.packages("PerformanceAnalytics")
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))
下面是控制台窗口中的 o/p
> getSymbols("AAPL")
[1] "AAPL"
Warning message:
In download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=", from.m, :
downloaded length 109721 != reported length 200
> 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))
Error in as.vector(Drawdowns(dailyRtn/100)) :
could not find function "Drawdowns"
当我成功安装并加载 PerformanceAnalytics 库时,我不明白为什么我会收到无法找到 Drawdowns 函数的错误消息