[R-SIG-Finance] Rounding time series to nearest 5mn

Kanin Kaninski kaninski2000 at yahoo.com
Sun Feb 14 18:00:59 CET 2010


Josh, Jeff, thank you for your answers. 

Jeff, I totally agree with you re: dangers of changing time stamps on observations. 

The issue here is that the data is pulled from BBG and should be in 5mn increments, so even though the time stamp shows 04:59, I'm 99% sure it really means 05:00. 

I guess you would argue that its more correct to keep it as 04:59 given that xts can handle this but my "quick and dirty" testing at this stage will suffer some intial productivity if I do this. Not super clean, but will get me through until I find out why the data from Bloomberg is not retrieved in multiples of 5mn...

Thank you again for your quick replies. Much appreciated.

/K


--- On Sun, 2/14/10, Jeff Ryan <jeff.a.ryan at gmail.com> wrote:

> From: Jeff Ryan <jeff.a.ryan at gmail.com>
> Subject: Re: [R-SIG-Finance] Rounding time series to nearest 5mn
> To: "Kanin Kaninski" <kaninski2000 at yahoo.com>
> Cc: r-sig-finance at stat.math.ethz.ch
> Date: Sunday, February 14, 2010, 4:59 AM
> > I would like to quantize the
> time stamps so that 00:04:59 becomes 00:05:00, i.e. rounding
> the time series to the nearest (in this case) 5 minutes.
> >
> 
> I general that is a bad idea, as you now have timestamps
> that refer to
> data that occurs in the future.  Might look nice, but
> will likely cost
> you money...
> 
> > What I could find on the net was the align function in
> the xts package. Unfortunately it doesnt really perform as
> expected: it has transformed a 5mn multiple timestamp (e.g.
> 00:00:00) into the next multiple (00:05:00). Moreover I
> understand that it always "round up" the time, rather than
> rounding to closest.
> 
> See above comment.  And per docs, it is as expected.
> 
> To clarify why 00:00:00 isn't set to 00:00:00, it is
> because the
> function aggregates all values within the time block (5 min
> here) and
> sets the time stamp to the beginning of the next
> block.  1:00:00 is
> the start of the hour, and everything from that point
> onward to 1:05
> (but not including) is pegged to 1:05.
> 
> Josh's reply should do what you want, but rounding down is
> a recipe
> for disaster.
> 
> HTH
> Jeff
> 
> >
> >> tSerie_align<-align.time(tSerie, n=300)
> >> head(tSerie_align)
> >                    LAST
> > 2009-12-15 00:05:00 "0.915447"
> > 2009-12-15 00:05:00 "0.916005"
> > 2009-12-15 00:10:00 "0.916167"
> > 2009-12-15 00:20:00 "0.9162"
> > 2009-12-15 00:25:00 "0.916188"
> > 2009-12-15 00:25:00 "0.916265"
> >
> > Any ideas how I could transform this time series to
> look as follows:
> >
> >                    LAST
> > 2009-12-15 00:00:00 "0.915447"
> > 2009-12-15 00:05:00 "0.916005"
> > 2009-12-15 00:10:00 "0.916167"
> > 2009-12-15 00:15:00 "0.9162"
> > 2009-12-15 00:20:00 "0.916188"
> > 2009-12-15 00:25:00 "0.916265"
> >
> > Thank you in advance.
> >
> > /K
> >
> > _______________________________________________
> > R-SIG-Finance at stat.math.ethz.ch
> 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.
> >
> 
> 
> 
> -- 
> Jeffrey Ryan
> jeffrey.ryan at insightalgo.com
> 
> ia: insight algorithmics
> www.insightalgo.com
> 






More information about the R-SIG-Finance mailing list