【问题标题】:SharpeRatio in PortfolioAnalytics package in RR 中 PortfolioAnalytics 包中的 SharpeRatio
【发布时间】:2015-04-25 23:52:25
【问题描述】:

我正在尝试使用 R 中的 PerformanceAnalytics 包计算回报系列的SharpRatio。 我的数据如下:

head(simpleRet)
  2006-01-02   2006-01-03   2006-01-04   2006-01-05   2006-01-06   2006-01-09 
 0.000000000  0.002495244  0.001018385 -0.001903177  0.002254347  0.002000196 

并且属于动物园类。 我正在使用代码:

library("PerformanceAnalytics")
SharpeRatio(simpleRet, Rf = 0.05, p = 0.95, FUN = "StdDev", weights = NULL, annualize = TRUE)
print(YY)

但我收到以下错误消息:

Error in FUNCT(R = R, p = p, ... = ..., invert = FALSE) : 
  'x' needs to be timeBased or xtsible, or scale must be specified.

有什么建议吗?

【问题讨论】:

    标签: r performanceanalytics


    【解决方案1】:

    也许这会有所帮助。

    sr <- SharpeRatio(simpleRet, Rf = 0.05, p = 0.95, FUN = "StdDev", scale=252)
    

    weightsannualize 参数具有默认值,因此无需指定它们。缺少参数是 scale。这是比例参数信息:

    scale   
    number of periods in a year (daily scale = 252, monthly scale = 12, quarterly scale = 4)
    

    【讨论】:

      猜你喜欢
      • 2018-07-09
      • 2021-01-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-18
      • 1970-01-01
      • 2020-08-07
      相关资源
      最近更新 更多