[R-SIG-Finance] [SPAM] - Pulling minute bar data with bar() function in Rbbg(RBloomberg) package in R - Email found in subject

David Reiner David.Reiner at xrtrading.com
Wed Aug 14 16:38:22 CEST 2013


Alex,
Sending your message in text instead of html will help you get an answer - see below for what we received.
But, no, you can go back further, but you must omit holidays the way you are doing it, since the empty
return from July 4 messes up your logic. The timeSequence function does take a FinCenter argument,
which may help you.

> start.date <- localToUTC('2013-04-01 08:30') # I'm in Chicago
> end.date <- localToUTC('2013-04-01 15:00')
> raw=bar(conn,"GOOG US Equity","TRADE",start.date,end.date,"60")
> head(raw)
                                           time    open    high     low   close numEvents volume
2013-04-01T13:30:00.000 2013-04-01T13:30:00.000 795.010 801.800 793.250 801.380      3650 512342
2013-04-01T14:30:00.000 2013-04-01T14:30:00.000 801.380 801.380 796.600 798.850      2323 320520
2013-04-01T15:30:00.000 2013-04-01T15:30:00.000 798.940 800.980 798.063 798.414      1063 152294
2013-04-01T16:30:00.000 2013-04-01T16:30:00.000 798.450 801.350 798.070 800.777       815 119642
2013-04-01T17:30:00.000 2013-04-01T17:30:00.000 800.860 802.209 800.500 801.280      1061 145566
2013-04-01T18:30:00.000 2013-04-01T18:30:00.000 801.155 801.330 799.550 799.750      1299 185598

HTH,
-- David Reiner
PS:
localToUTC <- function(x) {
  if (class(x)[1] == "character") {
    x <- as.POSIXct(x) # Assume strings are in the correct format
  }
  format(x, "%Y-%m-%d %H:%M:%OS3",tz="UTC")
}

-----Original Message-----
From: r-sig-finance-bounces at r-project.org [mailto:r-sig-finance-bounces at r-project.org] On Behalf Of Alex Bennett
Sent: Tuesday, August 13, 2013 8:18 PM
To: r-sig-finance at r-project.org
Subject: [SPAM] - [R-SIG-Finance] Pulling minute bar data with bar() function in Rbbg(RBloomberg) package in R - Email found in subject

I am fairly new to the Rbbg package, so please excuse any ignorance on my part, however I am wondering if it is possible to pull more than ~25 days of minute bar data using the bar() function. I've found I can't pull more than 25 or 26 days worth of data and am wondering if I am doing something wrong, or if it is just not possible.
Here is the code I am using:
#install.packages("rJava")#install.packages("Rbbg", repos="http://r.findata.org")#install.packages("timeDate")library(rJava)library(Rbbg)library(timeDate)conn <-blpConnect()weekdays =timeSequence(from=(Sys.Date()-38),to =(Sys.Date()-1),by="day")[isWeekday(timeSequence(from=(Sys.Date()-38),to =(Sys.Date()-1),by="day"))]date_time=numeric()volume=numeric()for(i in1:length(weekdays)){start.date <-paste(weekdays[i],"13:30:00.000")end.date <-paste(weekdays[i],"20:00:00.000")raw=bar(conn,"GOOG US Equity","TRADE",start.date,end.date,"1")date_time=append(date_time,raw$time)volume=append(volume,raw$volume)}date.time <-data.frame(do.call('rbind',strsplit(as.character(date_time),'T',fixed=TRUE)))use=data.frame("date"=format(as.Date(date.time$X1),"%m/%d/%Y"),"time"=date.time$X2,"volume"=raw$volume)blpDisconnect(conn)
This works fine and pulls data from the trading days in the past 3.5 weeks. Now, if I try to change the 38 to a greater number in the line weekdays = timeSequence(from = (Sys.Date()-38), to = (Sys.Date()-1), by = "day")[isWeekday(timeSequence(from = (Sys.Date()-38), to = (Sys.Date()-1), by = "day"))], I get the following error: Error in matrix.data[, 1] : subscript out of bounds when I try running the above script.
Is it the case that the API can only pull about 3.5 weeks of minute bar data? Or am I doing something incorrect? Ideally, I would like to have at least 100 trading days worth of data.
Thank you all for your help.
        [[alternative HTML version deleted]]



This e-mail and any materials attached hereto, including, without limitation, all content hereof and thereof (collectively, "XR Content") are confidential and proprietary to XR Trading, LLC ("XR") and/or its affiliates, and are protected by intellectual property laws.  Without the prior written consent of XR, the XR Content may not (i) be disclosed to any third party or (ii) be reproduced or otherwise used by anyone other than current employees of XR or its affiliates, on behalf of XR or its affiliates.

THE XR CONTENT IS PROVIDED AS IS, WITHOUT REPRESENTATIONS OR WARRANTIES OF ANY KIND.  TO THE MAXIMUM EXTENT PERMISSIBLE UNDER APPLICABLE LAW, XR HEREBY DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS AND IMPLIED, RELATING TO THE XR CONTENT, AND NEITHER XR NOR ANY OF ITS AFFILIATES SHALL IN ANY EVENT BE LIABLE FOR ANY DAMAGES OF ANY NATURE WHATSOEVER, INCLUDING, BUT NOT LIMITED TO, DIRECT, INDIRECT, CONSEQUENTIAL, SPECIAL AND PUNITIVE DAMAGES, LOSS OF PROFITS AND TRADING LOSSES, RESULTING FROM ANY PERSON'S USE OR RELIANCE UPON, OR INABILITY TO USE, ANY XR CONTENT, EVEN IF XR IS ADVISED OF THE POSSIBILITY OF SUCH DAMAGES OR IF SUCH DAMAGES WERE FORESEEABLE.



More information about the R-SIG-Finance mailing list