Hi i'm converting some 1 min data to 5 min data, and i'm finding it does 4 mins for the first increment, then goes on to do 5 min increments after that.
I've tried messing around with all the "indexAt" parameters but none give me what i want, which is starting from 5, then 10, 15, 20 etc.
i've tried
x5 <- to.minutes5(x)
AND
x <- to.period(x,
period = 'minutes',
k = 5,
OHLC = TRUE)
1 min data
Open High Low Close Volume
2013-01-16 00:01:00 93.55 93.60 93.54 93.58 5
2013-01-16 00:02:00 93.59 93.60 93.58 93.58 5
2013-01-16 00:03:00 93.59 93.60 93.58 93.58 5
2013-01-16 00:04:00 93.58 93.58 93.57 93.57 12
2013-01-16 00:05:00 93.57 93.57 93.55 93.70 21
2013-01-16 00:06:00 93.56 93.56 93.56 93.56 5
2013-01-16 00:07:00 93.56 93.56 93.55 93.55 3
2013-01-16 00:08:00 93.55 93.55 93.55 93.55 2
2013-01-16 00:09:00 93.55 93.56 93.55 93.56 2
2013-01-16 00:10:00 93.56 93.56 93.56 93.56 1
2013-01-16 00:11:00 93.57 93.57 93.57 93.57 3
after converting to 5 min
clemtest.Open clemtest.High clemtest.Low clemtest.Close clemtest.Volume
2013-01-16 00:04:00 93.55 93.60 93.54 93.57 27
2013-01-16 00:09:00 93.57 93.57 93.55 93.56 33
2013-01-16 00:14:00 93.56 93.57 93.56 93.57 8
2013-01-16 00:19:00 93.56 93.58 93.51 93.53 77
2013-01-16 00:24:00 93.53 93.55 93.49 93.49 121
2013-01-16 00:29:00 93.49 93.51 93.49 93.51 121
the calculations are correct, its just not starting with the first 5 mins of data, it start with 4 mins, then goes onto 5 mins after that.
(using indexAt='startof' gives me the correct, 5, 10, 15... but when inspecting the bar the 5 min data represents the start of that 5 min (eg min 5 - 10) not min 0 - 5)
Here is the tail of the 1min data for reference.
Open High Low Close Volume
2013-01-17 23:53:00 95.52 95.52 95.52 95.52 2
2013-01-17 23:55:00 95.51 95.52 95.51 95.52 2
2013-01-17 23:56:00 95.51 95.51 95.51 95.51 1
2013-01-17 23:57:00 95.52 95.52 95.52 95.52 1
2013-01-17 23:59:00 95.52 95.52 95.51 95.51 4
2013-01-18 00:00:00 95.51 95.51 95.51 95.51 8
to.period
(and thereforeto.minutes
,to.minutes5
, etc) use theendpoints
of each interval to aggregate the data. The last observation in the first 5 minutes of your data is at 00:04:00, which is what you see. 00:05:00 is the beginning of the second 5-minute interval in the zero hour. Can you add some detail about why you want to do this? – Joshua Ulrich