I have a bunch of 1 minute returns in an xts
object with the index being POSIXct
and time zone being GMT. The returns are on NYSE so I would like to convert to the eastern time zone but I would like to take care of the daylight savings time properly. What is the best way of doing this? I am a bit confused between the EST timezone and the EDT timezone. I would like my times to convert properly to the NY time in winter and summer.
Use indexTZ<-
and the America/New_York
timezone
> tail(SPY)
SPY.Bid.Price SPY.Ask.Price SPY.Trade.Price SPY.Mid.Price SPY.Volume
2012-08-09 19:54:00 140.47 140.48 140.48 140.475 2372
2012-08-09 19:55:00 140.46 140.47 140.46 140.465 5836
2012-08-09 19:56:00 140.47 140.48 140.48 140.475 2538
2012-08-09 19:57:00 140.47 140.48 140.47 140.475 2209
2012-08-09 19:58:00 140.48 140.49 140.49 140.485 4943
2012-08-09 19:59:00 140.58 140.59 140.58 140.585 16780
> indexTZ(SPY) <- "America/New_York"
> tail(SPY)
SPY.Bid.Price SPY.Ask.Price SPY.Trade.Price SPY.Mid.Price SPY.Volume
2012-08-09 15:54:00 140.47 140.48 140.48 140.475 2372
2012-08-09 15:55:00 140.46 140.47 140.46 140.465 5836
2012-08-09 15:56:00 140.47 140.48 140.48 140.475 2538
2012-08-09 15:57:00 140.47 140.48 140.47 140.475 2209
2012-08-09 15:58:00 140.48 140.49 140.49 140.485 4943
2012-08-09 15:59:00 140.58 140.59 140.58 140.585 16780
Warning message:
timezone of object (America/New_York) is different than current timezone (GMT).
来源:https://stackoverflow.com/questions/11917185/time-zones-in-posixct-and-xts-converting-from-gmt-in-r