[R-SIG-Finance] R Bloomberg for intraday prices

Brian G. Peterson brian at braverock.com
Wed Jan 4 16:47:57 CET 2012


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:  jsacks at russell.com
> 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}}
> 
> _______________________________________________
> 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.

-- 
Brian G. Peterson
http://braverock.com/brian/
Ph: 773-459-4973
IM: bgpbraverock



More information about the R-SIG-Finance mailing list