0

我正在尝试使用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")))
4

1 回答 1

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

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

于 2017-06-07T09:37:29.413 回答