[R-SIG-Finance] help on creating 5 minutes bars
R. Michael Weylandt
michael.weylandt at gmail.com
Mon Sep 24 12:14:54 CEST 2012
On Mon, Sep 24, 2012 at 9:57 AM, Chris de Bleu <blue2bleu at yahoo.fr> wrote:
> I would like to convert a 1 minute xts data to 5 minutes bars using "to.minutes5".
>
>> library(xts)
>
>> N = 20
>> s = xts(1:N, order.by = seq.POSIXt(ISOdate(2012, 9, 1), by = "min", length = N))
>> s
> [,1]
> 2012-09-01 12:00:00 1
> 2012-09-01 12:01:00 2
> 2012-09-01 12:02:00 3
> 2012-09-01 12:03:00 4
> 2012-09-01 12:04:00 5
> 2012-09-01 12:05:00 6
> 2012-09-01 12:06:00 7
> 2012-09-01 12:07:00 8
> 2012-09-01 12:08:00 9
> 2012-09-01 12:09:00 10
> 2012-09-01 12:10:00 11
> 2012-09-01 12:11:00 12
> 2012-09-01 12:12:00 13
> 2012-09-01 12:13:00 14
> 2012-09-01 12:14:00 15
> 2012-09-01 12:15:00 16
> 2012-09-01 12:16:00 17
> 2012-09-01 12:17:00 18
> 2012-09-01 12:18:00 19
> 2012-09-01 12:19:00 20
> Warning message:
> timezone of object (GMT) is different than current timezone ().
>> to.minutes5(s)
> s.Open s.High s.Low s.Close
> 2012-09-01 12:04:00 1 5 1 5
> 2012-09-01 12:09:00 6 10 6 10
> 2012-09-01 12:14:00 11 15 11 15
> 2012-09-01 12:19:00 16 20 16 20
> Warning message:
> timezone of object (GMT) is different than current timezone ().
>
>
> Why I haven't data at the 5 minutes with these timestamps?
Merely convention: to.period() goes to the _end_ of the unit being
aggregated rather than the beginning. This seems reasonable if you
consider a time stamp as when something can be known. (I.e., if you
marked periods as the beginning, use of "Hi" and "Lo" would introduce
a small but non-negligible look ahead into the simulation)
Cheers,
Michael
>
> 2012-09-01 12:00:00
> 2012-09-01 12:05:00
> 2012-09-01 12:10:00
> 2012-09-01 12:15:00
>
>
> Thank you,
> [[alternative HTML version deleted]]
>
>
> _______________________________________________
> R-SIG-Finance at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions should go.
More information about the R-SIG-Finance
mailing list