|
I was wondering if anyone has any luck additional information on the bar function in RBloomberg. My main issue is that it accepts/returns the data with GMT time stamp and has no feature to only show data during the trading hours for multiple days.
The Excel API allows you to use bdh function setting BarTp and BarSz but could not find this exposed in RBloomberg. Anyone have a work around? # Does not work bdh(conn, "SPY US Equity", "PX_LAST", "2011-12-29 6:30:00.000" , "2011-12-29 11:30:00.000", override_fields = c("BarType", "BarSize") , override_values = c("B","60")) I included the R ouput below. > Sys.timezone() [1] "PST" > > bar(conn, c("CSCO US Equity"), "BID", "2011-12-29 06:00:00.000" , "2011-12-30 13:00:00.000", "60") time open high low close 2011-12-29T09:00:00.000 2011-12-29T09:00:00.000 18.03 18.04 18.03 18.03 2011-12-29T10:00:00.000 2011-12-29T10:00:00.000 18.04 18.04 18.03 18.04 2011-12-29T11:00:00.000 2011-12-29T11:00:00.000 18.04 18.05 18.04 18.05 2011-12-29T12:00:00.000 2011-12-29T12:00:00.000 18.05 18.15 18.05 18.15 2011-12-29T13:00:00.000 2011-12-29T13:00:00.000 18.18 18.19 18.15 18.18 2011-12-29T14:00:00.000 2011-12-29T14:00:00.000 18.17 18.23 18.10 18.16 2011-12-29T15:00:00.000 2011-12-29T15:00:00.000 18.16 18.24 18.15 18.21 2011-12-29T16:00:00.000 2011-12-29T16:00:00.000 18.21 18.21 18.18 18.21 2011-12-29T17:00:00.000 2011-12-29T17:00:00.000 18.21 18.21 18.17 18.20 2011-12-29T18:00:00.000 2011-12-29T18:00:00.000 18.20 18.26 18.20 18.22 2011-12-29T19:00:00.000 2011-12-29T19:00:00.000 18.22 18.23 18.20 18.22 2011-12-29T20:00:00.000 2011-12-29T20:00:00.000 18.22 18.26 18.20 18.26 2011-12-29T21:00:00.000 2011-12-29T21:00:00.000 18.25 18.26 18.21 18.23 2011-12-29T22:00:00.000 2011-12-29T22:00:00.000 18.23 18.23 18.22 18.23 2011-12-29T23:00:00.000 2011-12-29T23:00:00.000 18.22 18.22 18.22 18.22 2011-12-30T00:00:00.000 2011-12-30T00:00:00.000 18.23 18.23 18.22 18.23 2011-12-30T08:30:00.000 2011-12-30T08:30:00.000 18.15 18.15 18.15 18.15 2011-12-30T09:30:00.000 2011-12-30T09:30:00.000 18.15 18.16 18.15 18.15 2011-12-30T10:30:00.000 2011-12-30T10:30:00.000 18.16 18.20 18.15 18.20 2011-12-30T11:30:00.000 2011-12-30T11:30:00.000 18.21 18.21 18.20 18.20 2011-12-30T12:30:00.000 2011-12-30T12:30:00.000 18.20 18.22 18.20 18.22 numEvents volume 2011-12-29T09:00:00.000 3 16 2011-12-29T10:00:00.000 10 57 2011-12-29T11:00:00.000 6 54 2011-12-29T12:00:00.000 8 97 2011-12-29T13:00:00.000 39 348 2011-12-29T14:00:00.000 7689 903201 2011-12-29T15:00:00.000 11117 2921269 2011-12-29T16:00:00.000 7043 2013271 2011-12-29T17:00:00.000 4849 1806055 2011-12-29T18:00:00.000 5662 2076844 2011-12-29T19:00:00.000 4092 991536 2011-12-29T20:00:00.000 9049 5146568 2011-12-29T21:00:00.000 47 2118 2011-12-29T22:00:00.000 8 132 2011-12-29T23:00:00.000 9 374 2011-12-30T00:00:00.000 7 117 2011-12-30T08:30:00.000 2 12 2011-12-30T09:30:00.000 5 18 2011-12-30T10:30:00.000 4 16 2011-12-30T11:30:00.000 2 8 2011-12-30T12:30:00.000 2 25 > (start.data <- as.POSIXct("2011-12-29 10:30:00.000")) [1] "2011-12-29 10:30:00 PST" > (end.data <- as.POSIXct("2011-12-29 12:00:00.000")) [1] "2011-12-29 12:00:00 PST" > bar(conn, c("CSCO US Equity"), "BID", start.data , end.data, "60") Error in FUN(X[[3L]], ...) : Sorry, parameter type `NA' is ambiguous or not supported. > # Does not work > bdh(conn, "SPY US Equity", "PX_LAST", "2011-12-29 6:30:00.000" , "2011-12-29 11:30:00.000", override_fields = + c("BarType", "BarSize") , override_values = c("B","60")) Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl, : org.findata.blpwrapper.WrapperException: response error: Invalid override field id specified [nid:809] Regards, John ___________________________________________ John J. Sacks, CFA Director, Quantitative Analysis Russell Implementation Services Inc. 1301 Second Ave., 18th Floor I Seattle, WA 98101 Ph: 206-505-1545 I Fx: 253-779-1074 I Email: [hidden email] SEVENTY-FIVE YEARS of Russell Innovation Russell Implementation Services Inc. is a part of Russell Investments and is a member of FINRA and SIPC. The information contained in this message is intended on...{{dropped:17}} _______________________________________________ [hidden email] 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. |
|
You can subset by time from the xts object you get out of RBloomberg.
On Wed, 2012-01-04 at 07:38 -0800, Sacks, John wrote: > I was wondering if anyone has any luck additional information on the bar function in RBloomberg. My main issue is that it accepts/returns the data with GMT time stamp and has no feature to only show data during the trading hours for multiple days. > > The Excel API allows you to use bdh function setting BarTp and BarSz but could not find this exposed in RBloomberg. Anyone have a work around? > > # Does not work > bdh(conn, "SPY US Equity", "PX_LAST", "2011-12-29 6:30:00.000" , "2011-12-29 11:30:00.000", override_fields = > c("BarType", "BarSize") , override_values = c("B","60")) > > I included the R ouput below. > > > Sys.timezone() > [1] "PST" > > > > bar(conn, c("CSCO US Equity"), "BID", "2011-12-29 06:00:00.000" , "2011-12-30 13:00:00.000", "60") > time open high low close > 2011-12-29T09:00:00.000 2011-12-29T09:00:00.000 18.03 18.04 18.03 18.03 > 2011-12-29T10:00:00.000 2011-12-29T10:00:00.000 18.04 18.04 18.03 18.04 > 2011-12-29T11:00:00.000 2011-12-29T11:00:00.000 18.04 18.05 18.04 18.05 > 2011-12-29T12:00:00.000 2011-12-29T12:00:00.000 18.05 18.15 18.05 18.15 > 2011-12-29T13:00:00.000 2011-12-29T13:00:00.000 18.18 18.19 18.15 18.18 > 2011-12-29T14:00:00.000 2011-12-29T14:00:00.000 18.17 18.23 18.10 18.16 > 2011-12-29T15:00:00.000 2011-12-29T15:00:00.000 18.16 18.24 18.15 18.21 > 2011-12-29T16:00:00.000 2011-12-29T16:00:00.000 18.21 18.21 18.18 18.21 > 2011-12-29T17:00:00.000 2011-12-29T17:00:00.000 18.21 18.21 18.17 18.20 > 2011-12-29T18:00:00.000 2011-12-29T18:00:00.000 18.20 18.26 18.20 18.22 > 2011-12-29T19:00:00.000 2011-12-29T19:00:00.000 18.22 18.23 18.20 18.22 > 2011-12-29T20:00:00.000 2011-12-29T20:00:00.000 18.22 18.26 18.20 18.26 > 2011-12-29T21:00:00.000 2011-12-29T21:00:00.000 18.25 18.26 18.21 18.23 > 2011-12-29T22:00:00.000 2011-12-29T22:00:00.000 18.23 18.23 18.22 18.23 > 2011-12-29T23:00:00.000 2011-12-29T23:00:00.000 18.22 18.22 18.22 18.22 > 2011-12-30T00:00:00.000 2011-12-30T00:00:00.000 18.23 18.23 18.22 18.23 > 2011-12-30T08:30:00.000 2011-12-30T08:30:00.000 18.15 18.15 18.15 18.15 > 2011-12-30T09:30:00.000 2011-12-30T09:30:00.000 18.15 18.16 18.15 18.15 > 2011-12-30T10:30:00.000 2011-12-30T10:30:00.000 18.16 18.20 18.15 18.20 > 2011-12-30T11:30:00.000 2011-12-30T11:30:00.000 18.21 18.21 18.20 18.20 > 2011-12-30T12:30:00.000 2011-12-30T12:30:00.000 18.20 18.22 18.20 18.22 > numEvents volume > 2011-12-29T09:00:00.000 3 16 > 2011-12-29T10:00:00.000 10 57 > 2011-12-29T11:00:00.000 6 54 > 2011-12-29T12:00:00.000 8 97 > 2011-12-29T13:00:00.000 39 348 > 2011-12-29T14:00:00.000 7689 903201 > 2011-12-29T15:00:00.000 11117 2921269 > 2011-12-29T16:00:00.000 7043 2013271 > 2011-12-29T17:00:00.000 4849 1806055 > 2011-12-29T18:00:00.000 5662 2076844 > 2011-12-29T19:00:00.000 4092 991536 > 2011-12-29T20:00:00.000 9049 5146568 > 2011-12-29T21:00:00.000 47 2118 > 2011-12-29T22:00:00.000 8 132 > 2011-12-29T23:00:00.000 9 374 > 2011-12-30T00:00:00.000 7 117 > 2011-12-30T08:30:00.000 2 12 > 2011-12-30T09:30:00.000 5 18 > 2011-12-30T10:30:00.000 4 16 > 2011-12-30T11:30:00.000 2 8 > 2011-12-30T12:30:00.000 2 25 > > (start.data <- as.POSIXct("2011-12-29 10:30:00.000")) > [1] "2011-12-29 10:30:00 PST" > > (end.data <- as.POSIXct("2011-12-29 12:00:00.000")) > [1] "2011-12-29 12:00:00 PST" > > bar(conn, c("CSCO US Equity"), "BID", start.data , end.data, "60") > Error in FUN(X[[3L]], ...) : > Sorry, parameter type `NA' is ambiguous or not supported. > > # Does not work > > bdh(conn, "SPY US Equity", "PX_LAST", "2011-12-29 6:30:00.000" , "2011-12-29 11:30:00.000", override_fields = > + c("BarType", "BarSize") , override_values = c("B","60")) > Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl, : > org.findata.blpwrapper.WrapperException: response error: Invalid override field id specified [nid:809] > > > > Regards, > John > ___________________________________________ > John J. Sacks, CFA > Director, Quantitative Analysis > Russell Implementation Services Inc. > 1301 Second Ave., 18th Floor I Seattle, WA 98101 > Ph: 206-505-1545 I Fx: 253-779-1074 I Email: [hidden email] > SEVENTY-FIVE YEARS of Russell Innovation > Russell Implementation Services Inc. is a part of Russell Investments and is a member of FINRA and SIPC. > The information contained in this message is intended on...{{dropped:17}} > > _______________________________________________ > [hidden email] 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. -- Brian G. Peterson http://braverock.com/brian/ Ph: 773-459-4973 IM: bgpbraverock _______________________________________________ [hidden email] 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. |
|
In reply to this post by Sacks, John
Were you able to get an answer to this question?
The timestamp is in UTC time - so how does one convert this time to US trading hours i.e 9:30 to 4pm? How does one handle the day light savings hours etc... Appreciate the feedback. |
|
See ?indexTZ
-- Sent from my Android phone with K-9 Mail. Please excuse my brevity. algotr8der <[hidden email]> wrote: Were you able to get an answer to this question? The timestamp is in UTC time - so how does one convert this time to US trading hours i.e 9:30 to 4pm? How does one handle the day light savings hours etc... Appreciate the feedback. -- View this message in context: http://r.789695.n4.nabble.com/R-Bloomberg-for-intraday-prices-tp4261687p4524206.html Sent from the Rmetrics mailing list archive at Nabble.com. _____________________________________________ [hidden email] 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. [[alternative HTML version deleted]] _______________________________________________ [hidden email] 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. |
|
In reply to this post by algotr8der
Use the lubridate package. Here are some links
http://cran.r-project.org/web/packages/lubridate/index.html http://www.jstatsoft.org/v40/i03/paper http://www.r-statistics.com/2012/03/do-more-with-dates-and-times-in-r-with-lubridate-1-1-0/ Alain (646)781-2698 -----Original Message----- From: [hidden email] [mailto:[hidden email]] On Behalf Of algotr8der Sent: Sunday, April 01, 2012 3:36 PM To: [hidden email] Subject: Re: [R-SIG-Finance] R Bloomberg for intraday prices Were you able to get an answer to this question? The timestamp is in UTC time - so how does one convert this time to US trading hours i.e 9:30 to 4pm? How does one handle the day light savings hours etc... Appreciate the feedback. -- View this message in context: http://r.789695.n4.nabble.com/R-Bloomberg-for-intraday-prices-tp4261687p4524206.html Sent from the Rmetrics mailing list archive at Nabble.com. _______________________________________________ [hidden email] 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. _______________________________________________ [hidden email] 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. |
|
Hi Alain - thanks for the suggestion.
I tried to feed the first column of the data frame object created by RBloomberg to with_tz() and I got the following error: > head(SMH) time open high low close numEvents volume 2011-09-19T13:30:00.000 2011-09-19T13:30:00.000 30.52 30.550 30.460 30.49 319 105000 2011-09-19T13:31:00.000 2011-09-19T13:31:00.000 30.48 30.520 30.470 30.50 198 63700 2011-09-19T13:32:00.000 2011-09-19T13:32:00.000 30.49 30.590 30.480 30.56 260 98800 2011-09-19T13:33:00.000 2011-09-19T13:33:00.000 30.56 30.610 30.530 30.53 106 20900 2011-09-19T13:34:00.000 2011-09-19T13:34:00.000 30.53 30.545 30.525 30.53 89 24900 2011-09-19T13:35:00.000 2011-09-19T13:35:00.000 30.53 30.540 30.495 30.53 648 159000 > with_tz(SMH[,1], "EST") Error in UseMethod("reclass_date", orig) : no applicable method for 'reclass_date' applied to an object of class "character" > with_tz(SMH[,1], tz="America/New_york") Error in UseMethod("reclass_date", orig) : no applicable method for 'reclass_date' applied to an object of class "character" Firstly, I'm not sure why RBloomberg creates the date/timestamp as follows: 2011-09-19T13:35:00.000 Why attach a 'T' between the date and the time? This type of format looks very foreign to me and my guess is this is why with_tz returns an exception. Any thoughts would be greatly appreciated. Thank you. |
|
TZ management in xts is widely used and very well tested.
There isn't a need to use lubridate IMO. Recast as xts (a proper time series) and look at the vignettes associated as well as indexTZ documentation as Brian Peterson said. Best, Jeff Jeffrey Ryan | Founder | [hidden email] www.lemnica.com On Apr 3, 2012, at 8:14 PM, algotr8der <[hidden email]> wrote: > Hi Alain - thanks for the suggestion. > > I tried to feed the first column of the data frame object created by > RBloomberg to with_tz() and I got the following error: > >> head(SMH) > time open high low close > numEvents volume > 2011-09-19T13:30:00.000 2011-09-19T13:30:00.000 30.52 30.550 30.460 30.49 > 319 105000 > 2011-09-19T13:31:00.000 2011-09-19T13:31:00.000 30.48 30.520 30.470 30.50 > 198 63700 > 2011-09-19T13:32:00.000 2011-09-19T13:32:00.000 30.49 30.590 30.480 30.56 > 260 98800 > 2011-09-19T13:33:00.000 2011-09-19T13:33:00.000 30.56 30.610 30.530 30.53 > 106 20900 > 2011-09-19T13:34:00.000 2011-09-19T13:34:00.000 30.53 30.545 30.525 30.53 > 89 24900 > 2011-09-19T13:35:00.000 2011-09-19T13:35:00.000 30.53 30.540 30.495 30.53 > 648 159000 > >> with_tz(SMH[,1], "EST") > Error in UseMethod("reclass_date", orig) : > no applicable method for 'reclass_date' applied to an object of class > "character" > >> with_tz(SMH[,1], tz="America/New_york") > Error in UseMethod("reclass_date", orig) : > no applicable method for 'reclass_date' applied to an object of class > "character" > > Firstly, I'm not sure why RBloomberg creates the date/timestamp as follows: > > 2011-09-19T13:35:00.000 > > Why attach a 'T' between the date and the time? This type of format looks > very foreign to me and my guess is this is why with_tz returns an exception. > > Any thoughts would be greatly appreciated. Thank you. > > > -- > View this message in context: http://r.789695.n4.nabble.com/R-Bloomberg-for-intraday-prices-tp4261687p4530646.html > Sent from the Rmetrics mailing list archive at Nabble.com. > > _______________________________________________ > [hidden email] 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. _______________________________________________ [hidden email] 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. |
|
In reply to this post by algotr8der
To directly answer the question though, that format is ISO 8601, which is just the standard way of unambiguously representing dates and times.
Best, Jeff Jeffrey Ryan | Founder | [hidden email] www.lemnica.com On Apr 3, 2012, at 8:14 PM, algotr8der <[hidden email]> wrote: > Hi Alain - thanks for the suggestion. > > I tried to feed the first column of the data frame object created by > RBloomberg to with_tz() and I got the following error: > >> head(SMH) > time open high low close > numEvents volume > 2011-09-19T13:30:00.000 2011-09-19T13:30:00.000 30.52 30.550 30.460 30.49 > 319 105000 > 2011-09-19T13:31:00.000 2011-09-19T13:31:00.000 30.48 30.520 30.470 30.50 > 198 63700 > 2011-09-19T13:32:00.000 2011-09-19T13:32:00.000 30.49 30.590 30.480 30.56 > 260 98800 > 2011-09-19T13:33:00.000 2011-09-19T13:33:00.000 30.56 30.610 30.530 30.53 > 106 20900 > 2011-09-19T13:34:00.000 2011-09-19T13:34:00.000 30.53 30.545 30.525 30.53 > 89 24900 > 2011-09-19T13:35:00.000 2011-09-19T13:35:00.000 30.53 30.540 30.495 30.53 > 648 159000 > >> with_tz(SMH[,1], "EST") > Error in UseMethod("reclass_date", orig) : > no applicable method for 'reclass_date' applied to an object of class > "character" > >> with_tz(SMH[,1], tz="America/New_york") > Error in UseMethod("reclass_date", orig) : > no applicable method for 'reclass_date' applied to an object of class > "character" > > Firstly, I'm not sure why RBloomberg creates the date/timestamp as follows: > > 2011-09-19T13:35:00.000 > > Why attach a 'T' between the date and the time? This type of format looks > very foreign to me and my guess is this is why with_tz returns an exception. > > Any thoughts would be greatly appreciated. Thank you. > > > -- > View this message in context: http://r.789695.n4.nabble.com/R-Bloomberg-for-intraday-prices-tp4261687p4530646.html > Sent from the Rmetrics mailing list archive at Nabble.com. > > _______________________________________________ > [hidden email] 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. _______________________________________________ [hidden email] 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. |
|
This post was updated on .
In reply to this post by Jeffrey Ryan
Thanks Jeff and Brian!
I'm still having issues... I did the following: My starting object is SMH, which was created by result of a query of the bar function in the RBloomberg package. My machine's timezone is EDT. > Sys.timezone() [1] "EDT" > head(SMH) time open high low close 2011-09-19T13:30:00.000 2011-09-19T13:30:00.000 30.52 30.550 30.460 30.49 2011-09-19T13:31:00.000 2011-09-19T13:31:00.000 30.48 30.520 30.470 30.50 2011-09-19T13:32:00.000 2011-09-19T13:32:00.000 30.49 30.590 30.480 30.56 2011-09-19T13:33:00.000 2011-09-19T13:33:00.000 30.56 30.610 30.530 30.53 2011-09-19T13:34:00.000 2011-09-19T13:34:00.000 30.53 30.545 30.525 30.53 2011-09-19T13:35:00.000 2011-09-19T13:35:00.000 30.53 30.540 30.495 30.53 numEvents volume 2011-09-19T13:30:00.000 319 105000 2011-09-19T13:31:00.000 198 63700 2011-09-19T13:32:00.000 260 98800 2011-09-19T13:33:00.000 106 20900 2011-09-19T13:34:00.000 89 24900 2011-09-19T13:35:00.000 648 159000 1) strptime(SMH[,1], format="%Y-%m-%dT%H:%M:%S") -> date_time 2) rownames(SMH) <- date_time 3) now the row label is in the format YYYY-mm-dd H:M:S > head(SMH) open high low close numEvents volume 2011-09-19 13:30:00 30.52 30.550 30.460 30.49 319 105000 2011-09-19 13:31:00 30.48 30.520 30.470 30.50 198 63700 2011-09-19 13:32:00 30.49 30.590 30.480 30.56 260 98800 2011-09-19 13:33:00 30.56 30.610 30.530 30.53 106 20900 2011-09-19 13:34:00 30.53 30.545 30.525 30.53 89 24900 2011-09-19 13:35:00 30.53 30.540 30.495 30.53 648 159000 > str(SMH) 'data.frame': 48694 obs. of 6 variables: $ open : num 30.5 30.5 30.5 30.6 30.5 ... $ high : num 30.6 30.5 30.6 30.6 30.5 ... $ low : num 30.5 30.5 30.5 30.5 30.5 ... $ close : num 30.5 30.5 30.6 30.5 30.5 ... $ numEvents: num 319 198 260 106 89 648 190 171 221 255 ... $ volume : num 105000 63700 98800 20900 24900 ... 4) Create an XTS object: as.xts(as.data.frame(SMH)) -> SMH.xts.1 Notice that the tzone = null. Also notice that the time has NOT changed > str(SMH.xts.1) An ‘xts’ object from 2011-09-19 13:30:00 to 2012-03-30 20:15:00 containing: Data: num [1:48694, 1:6] 30.5 30.5 30.5 30.6 30.5 ... - attr(*, "dimnames")=List of 2 ..$ : NULL ..$ : chr [1:6] "open" "high" "low" "close" ... Indexed by objects of class: [POSIXct,POSIXt] TZ: xts Attributes: List of 2 $ tclass: chr [1:2] "POSIXct" "POSIXt" $ tzone : chr "" > head(SMH.xts.1) open high low close numEvents volume 2011-09-19 13:30:00 30.52 30.550 30.460 30.49 319 105000 2011-09-19 13:31:00 30.48 30.520 30.470 30.50 198 63700 2011-09-19 13:32:00 30.49 30.590 30.480 30.56 260 98800 2011-09-19 13:33:00 30.56 30.610 30.530 30.53 106 20900 2011-09-19 13:34:00 30.53 30.545 30.525 30.53 89 24900 2011-09-19 13:35:00 30.53 30.540 30.495 30.53 648 159000 5) create another XTS but specify the tzone in the creation of the xts object since as per RBloomberg documentation the time specified in the bar function (used to extract the data in the first place) is in UTC: --snippet from RBloomberg documentation --- Period start and end times must be expressed as strings in UTC time. bar <- function(conn, security, field, start_date_time, end_date_time, interval) --end snippet------- as.xts(as.data.frame(SMH), tzone="UTC") -> SMH.xts.2 > head(SMH.xts.2) open high low close numEvents volume 2011-09-19 17:30:00 30.52 30.550 30.460 30.49 319 105000 2011-09-19 17:31:00 30.48 30.520 30.470 30.50 198 63700 2011-09-19 17:32:00 30.49 30.590 30.480 30.56 260 98800 2011-09-19 17:33:00 30.56 30.610 30.530 30.53 106 20900 2011-09-19 17:34:00 30.53 30.545 30.525 30.53 89 24900 2011-09-19 17:35:00 30.53 30.540 30.495 30.53 648 159000 Warning message: timezone of object (UTC) is different than current timezone (). Notice that the time changes..... the PROBLEM I have - at least this is what I believe the problem to be - is that the time specified in the original object is already UTC. This is why I want to force the tzone field to UTC in my call to as.xts. But by doing so it actually performs a conversion, which I believe is from EDT to UTC since my machine's timezone is EDT. The first data point in the original object occurred at 13:30. By forcing UTC, the new time changes to 17:30 because it thinks I want to convert from EDT to UTC when in fact I just want to tell R that the object is UTC time so I can convert it to EDT regular trading hours. Any thoughts on how I can achieve this without changing the timezone on my machine? Greatly appreciate your help. |
|
Try
> strptime(t, format="%Y-%m-%dT%H:%M:%S", tz="UTC") # note tz= <<<<<<<<< [1] "2011-09-19 13:30:00 UTC" Then > xts(1, strptime(t, format="%Y-%m-%dT%H:%M:%S", tz="UTC"), >tzone="America/Chicago") [,1] 2011-09-19 08:30:00 1 > xts(1, strptime(t, format="%Y-%m-%dT%H:%M:%S", tz="UTC"), >tzone="America/New_York") [,1] 2011-09-19 09:30:00 1 Warning message: timezone of object (America/New_York) is different than current timezone (America/Chicago). Which looks right-ish to me. You can store it in whatever TZ you want, the warning is just telling you that something is different and you should be aware. Probably need to have a flag to disable that - or only show once... HTH Jeff On 4/5/12 2:29 PM, "algotr8der" <[hidden email]> wrote: >%Y-%m-%dT%H:%M:%S" _______________________________________________ [hidden email] 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. |
| Powered by Nabble | Edit this page |
