【问题标题】:charts.PerformanceSummary() not working for intraday datachart.PerformanceSummary() 不适用于日内数据
【发布时间】:2017-11-08 10:37:00
【问题描述】:

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

【问题讨论】:

    标签: r performanceanalytics


    【解决方案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
    

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-02-27
      • 1970-01-01
      • 1970-01-01
      • 2018-11-22
      • 2015-02-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多