I am trying to use R XTS package to.minutes to create 15m and 30m time series from 5m. I have an xts object, which is date-time followed by OHLC. Info about xts object x is below:
head(x) shows the following:
High Low Open Close Volume
2010-05-03 09:00:00 106.08 105.95 106.06 106.00 1055
2010-05-03 09:05:00 106.03 105.75 106.00 105.77 4369
2010-05-03 09:10:00 105.77 105.59 105.77 105.68 4125
2010-05-03 09:15:00 105.84 105.66 105.69 105.80 2457
2010-05-03 09:20:00 105.89 105.71 105.80 105.83 1788
2010-05-03 09:25:00 105.89 105.78 105.84 105.78 977
str(x) shows the following:
> str(x)
‘zoo’ series from 2010-05-03 09:00:00 to 2013-06-10 14:30:00
Data: num [1:222473, 1:5] 106 106 106 106 106 ...
- attr(*, "dimnames")=List of 2
..$ : NULL
..$ : chr [1:5] "High" "Low" "Open" "Close" ...
Index: POSIXct[1:222473], format: "2010-05-03 09:00:00" "2010-05-03 09:05:00" "2010-05-03 09:10:00" ...
str(head(index(x))) shows the following:
head(str(index(x)))
POSIXct[1:222473], format: "2010-05-03 09:00:00" "2010-05-03 09:05:00" "2010-05-03 09:10:00" ...
NULL
When I convert the time series to 15m, the series starts at 09:10:00 followed by 15 minutes increments instead of starting at 09:15:00 followed by 15 minutes increments
> head(to.minutes(x, k=15))
x.Open x.High x.Low x.Close x.Volume
2010-05-03 09:10:00 106.08 105.95 105.77 105.68 9549
2010-05-03 09:25:00 105.84 105.78 105.69 105.78 5222
2010-05-03 09:40:00 105.80 105.92 105.62 106.12 9727
2010-05-03 09:55:00 106.17 106.00 106.01 106.22 6320
2010-05-03 10:10:00 106.26 106.07 106.15 106.14 8422
2010-05-03 10:25:00 106.57 106.38 106.15 106.37 10422
The same issue when I convert the time series to 30m, the series starts at 09:25:00 followed by 30 minutes increments instead of starting at 09:30:00 followed by 30 minutes increments
> head(to.minutes(x, k=30))
x.Open x.High x.Low x.Close x.Volume
2010-05-03 09:25:00 106.08 105.95 105.69 105.78 14771
2010-05-03 09:55:00 105.80 106.00 105.62 106.22 16047
2010-05-03 10:25:00 106.26 106.38 106.15 106.37 18844
2010-05-03 10:55:00 106.37 106.27 106.01 106.00 17193
2010-05-03 11:25:00 106.04 106.20 105.95 106.29 9075
2010-05-03 11:55:00 106.34 106.35 106.24 106.39 8517
I also tried the same using 1 minute data and had the same issue. Any thought on what might be causing this issue and how to resolve it? Thanks