charts.PerformanceSummary()不适用于日内数据

时间:2017-06-07 07:41:19

标签: r performanceanalytics

我正在尝试使用PerformanceAnalytics::charts.PerformanceSummary()

绘制日内数据

但是我收到以下错误消息:

charts.PerformanceSummary(e[,1:10])

Error in as.POSIXlt.POSIXct(.POSIXct(.index(x)), tz = indexTZ(x)) : 
      invalid 'tz' value

charts.PerformanceSummary似乎只收集每日数据而不是当日数据?

有人可以为此提出解决方案吗?

 e <- structure(c(0, 0, 0, 0, 0, 0, 0, 0, 0.000369303493611195, 0, 
0, 0.000590667454223315, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.000150829562594268, 
0.000150806816467952, -0.00015078407720126, -0.000150806816468174, 
0.000301659125188536, 0, 0, -0.000617817867292869, 0, 0, 0, 0, 
0.000107944732297138, 0.000323799244468459, -0.000215796288303927, 
0, 0.000215842866393423, 0, 0, 0, 0, 0, 0), class = c("xts", 
"zoo"), .indexCLASS = c("POSIXlt", "POSIXt"), tclass = c("POSIXlt", 
"POSIXt"), .indexTZ = c("America/New_York", "EST", "EDT"), tzone = c("America/New_York", 
"EST", "EDT"), index = structure(c(1496755860, 1496755920, 1496755980, 
1496756040, 1496756100, 1496756160), tzone = c("America/New_York", 
"EST", "EDT"), tclass = c("POSIXlt", "POSIXt")), .Dim = c(6L, 
10L), .Dimnames = list(NULL, c("AADR", "AAXJ", "ACIM", "ACSI", 
"ACTX", "ACWF", "ACWI", "ACWV", "ACWX", "ADRA")))

1 个答案:

答案 0 :(得分:1)

问题是POSIXlt索引。您应该将其转换为POSIXct,这最容易通过创建新的xts对象来完成。请尝试以下命令。

e <- xts(coredata(e), as.POSIXct(index(e)))
PerformanceAnalytics::charts.PerformanceSummary(e[,1:10])

在绘制第一个图之后,图表会引发示例数据错误:

Error in segments(xlim[1], y_grid_lines(ylim), xlim[2], y_grid_lines(ylim),  : 
  cannot mix zero-length and non-zero-length coordinates

但这可能是因为没有足够的观察结果。如果它对您的实际数据不起作用,请告诉我,我会进一步调查。