【问题标题】:SharpeRatio.annualized() not working Performance AnalyticsSharpeRatio.annualized() 不工作性能分析
【发布时间】:2012-11-08 02:54:58
【问题描述】:

已经使用 Performance Analytics 的 SharpeRatio.annualized() 函数一段时间了,没有任何问题。最近,我一直收到错误

Error in xts(rep(Rf, length(indexseries)), order.by = indexseries) : 
  order.by requires an appropriate time-based object

当我运行这个时:

library(PerformanceAnalytics)
library(quantmod)

myEnv <- new.env()
getSymbols(c("AAPL","GOOG"), src = "yahoo", from = "2004-04-01", to = "2012-09-30", env = myEnv)
index <- do.call(merge, c(eapply(myEnv, Ad), all=TRUE))

index.ret <- (index / lag(index,1) - 1)[-1,]

SharpeRatio.annualized(index.ret[,1])

运行Return.annualized(index.ret[,1])sd.annualized(index.ret[,1]) 没有问题。其他人有这个问题或知道我做错了什么?

编辑 - 会话信息

> sessionInfo()
R version 2.15.1 (2012-06-22)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)

locale:
[1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] quantmod_0.3-17              TTR_0.21-1                   Defaults_1.1-1               PerformanceAnalytics_1.0.4.4
[5] xts_0.8-8                    zoo_1.7-9                   

loaded via a namespace (and not attached):
[1] digest_0.5.2    evaluate_0.4.2  formatR_0.6     grid_2.15.1     knitr_0.8       lattice_0.20-10 plyr_1.7.1     
[8] stringr_0.6.1   tools_2.15.1   

【问题讨论】:

  • 请将您的sessionInfo() 添加到问题中。
  • 它适用于我(在 Linux 上),附带相同版本的软件包。 (R 2.15.2,不是 2.15.1)。我没有加载digest_0.5.2 evaluate_0.4.2 formatR_0.6 knitr_0.8 plyr_1.7.1 stringr_0.6.1 tools_2.15.1。也许尝试删除它们中的每一个?和/或发布str(index.ret)

标签: r xts performanceanalytics


【解决方案1】:

我加载了Systematic Investor Toolbox,这就是问题的原因。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-29
    • 2011-12-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多