2015-02-24 59 views
1

我試圖計算的使用R. 包PerformanceAnalytics我的數據看起來如下返回系列sharpRatio:SharpeRatio在PortfolioAnalytics包中的R

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 

,是一流的動物園。使用 I'mm代碼:

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. 

有什麼建議?

回答

0

也許這可以提供幫助。

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

年率參數都有默認值,所以沒有必要指定它們。缺少的參數是比例尺。這裏是比例參數信息:

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