嗨我有像这样的xts格式的数据
> ITXxts
Time Price Volume
2014-07-18 09:00:00 67.63 460
2012-04-27 09:00:00 67.63 73
2012-04-27 09:00:00 67.63 85
2012-04-27 09:00:01 67.63 3
2012-04-27 09:01:03 67.79 1
2012-04-27 09:01:16 67.64 91
2012-04-27 09:05:50 67.83 75
现在将该系列汇总为5分钟
tsagg5min =aggregatets(ITXxts,on="minutes",k=5)
2014-07-18 09:05:00 67.45 43
2014-07-18 09:10:00 67.82 12
2014-07-18 09:15:00 67.91 341
2014-07-18 09:20:00 67.70 275
ChartSeries中(tsagg5min)
现在我的问题是我想以OHLC格式绘制它,以便计算汇总数据的每5分钟块的开盘高点和收盘价
答案 0 :(得分:3)
xts
包(由quantmod加载)具有转换为OHLC条的功能。
tsagg5min <- to.minutes5(ITXxts)
#tsagg5min <- to.minutes(ITXxts, k=5) # identical
#tsagg5min <- to.period(ITXxts, endpoints(ITXxts, "minutes", k=5)) # identical
chartSeries(tsagg5min)