[R-SIG-Finance] getting xts endpoints() and apply.daiy() to work with local TZ?
jeff.a.ryan at gmail.com
Wed Jul 8 14:33:16 CEST 2009
endpoints was patched about two weeks ago on R-forge for this issue.
You can install from there, or there will be a new CRAN version coming
in the next few weeks (after Rennes).
The fixed version with commit log:
To install from R-forge:
Thanks again for the report and suggestion!
On Wed, Jul 8, 2009 at 1:26 AM, Christian Gunning<icos.atropa at gmail.com> wrote:
> I'm looking for the best way to get apply.daily() to use breaks
> according to local TZ. Sorry, i know timezone handling is perennial
> issue. I reviewed R News 4/1, R-sig-fin, ?indexTZ, and
> ?DateTimeClasses and xts R source.
> Currently, apply.daily() in a non-GMT timezone computes breaks
> according to GMT (A note about this in apply.daily() or endpoints()
> might preempt user confusion?).
> Below, I compute the difference between local time and GMT in seconds,
> and add it into the call to which() in endpoints() to get my desired
> answer. Is endpoints() support of TZ on the map, and is there a better
> way than this to add it (particularly, calculating tmpdiff below)? Is
> this a bad idea altogether?
> christian gunning
> university of new mexico
> oldtz = Sys.getenv('TZ')
> tmpind = as.POSIXct(seq(from=0, to=5*24*60*60-60, by=60*60),
> tmpx = xts(1:(5*24), tmpind)
> indexTZ(tmpx) ### correctly reports TZ as "GMT+7"
> tmpind ### format.POSIXlt? reports TZ as "GMT",
> tmpx[endpoints(tmpx, on='days')] ### daybreaks as per GMT
> ### from endpoints(), added tmpdiff, daybreaks as per local TZ
> tmpdiff = as.integer(as.POSIXct(0, origin='2000-01-01', tz='GMT')) -
> as.integer(as.POSIXct(0, origin='2000-01-01'))
> tmpdays = as.integer(c(0,
> which(diff((.index(tmpx)+tmpdiff)%/%86400L%/%k + 1) != 0),
> R-SIG-Finance at stat.math.ethz.ch mailing list
> -- Subscriber-posting only.
> -- If you want to post, subscribe first.
jeffrey.ryan at insightalgo.com
ia: insight algorithmics
More information about the R-SIG-Finance