bloomberg - Pulling minute bar data with bar() function in Rbbg (RBloomberg) package in R -
i new rbbg package, please excuse ignorance on part, wondering if possible pull more ~25 days of minute bar data using bar()
function. i've found can't pull more 25 or 26 days worth of data , wondering if doing wrong, or if not possible.
here code 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), = (sys.date()-1), = "day")[isweekday(timesequence(from = (sys.date()-38), = (sys.date()-1), = "day"))] date_time=numeric() volume=numeric() for(i in 1:length(weekdays)){ start.date <- paste(weekdays[i],"13:30:00.000") end.date <- paste(weekdays[i],"20:00:00.000") raw=bar(conn, "goog 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 , pulls data trading days in past 3.5 weeks. now, if try change 38 greater number in line weekdays = timesequence(from = (sys.date()-38), = (sys.date()-1), = "day")[isweekday(timesequence(from = (sys.date()-38), = (sys.date()-1), = "day"))]
, following error: error in matrix.data[, 1] : subscript out of bounds
when try running above script.
is case api can pull 3.5 weeks of minute bar data? or doing incorrect? ideally, have @ least 100 trading days worth of data.
thank help.
bloomberg delivers 6 months of intraday data. if use function bardata our r package rbbgextension (can found @ github) on google 1-minute bars 6 months back. clarify why convert times gmt because european equities trade across multiple time zones starts @ same time, data time aligned convert prices gmt.
> goog.bar <- bardata(tickers = "goog us", + type = "equity", + start.date.time = "2014-01-01 09:30:00", + end.date.time = "2015-01-21 16:05:00", + time.zone = "america/new_york", + interval = "1") r version 3.1.0 (2014-04-10) rjava version 0.9-6 rbbg version 0.5.2 java environment initialized successfully. looking recent blpapi3.jar file... adding c:\blp\api\apiv3\javaapi\v3.7.1.1\lib\blpapi3.jar java classpath bloomberg api version 3.7.1.1 > head(goog.bar) open high low close numevents volume 2014-07-10 13:30:00 565.910 566.85 565.01 565.745 142 38862 2014-07-10 13:31:00 565.500 566.06 565.01 565.190 49 7606 2014-07-10 13:32:00 565.110 566.70 565.11 566.350 49 6878 2014-07-10 13:33:00 566.390 566.60 566.00 566.600 34 4473 2014-07-10 13:34:00 566.470 566.48 565.65 565.850 52 6365 2014-07-10 13:35:00 565.775 566.45 565.55 566.050 107 14513 warning message: timezone of object (gmt) different current timezone (). > tail(goog.bar) open high low close numevents volume 2015-01-21 20:54:00 518.00 518.520 518.00 518.275 135 15492 2015-01-21 20:55:00 518.31 518.500 518.22 518.230 116 14048 2015-01-21 20:56:00 518.23 518.374 518.22 518.350 83 9696 2015-01-21 20:57:00 518.35 518.390 518.18 518.250 99 12289 2015-01-21 20:58:00 518.25 518.640 518.20 518.420 116 15353 2015-01-21 20:59:00 518.39 518.390 517.80 518.040 309 101288 warning message: timezone of object (gmt) different current timezone ().
however, able error. if don't specify actual end date/time, output highlight. point precise end date/time.
> goog.bar <- bardata(tickers = "goog us", + type = "equity", + start.date.time = "2014-01-01 09:30:00", + time.zone = "america/new_york", + interval = "1") r version 3.1.0 (2014-04-10) rjava version 0.9-6 rbbg version 0.5.2 java environment initialized successfully. looking recent blpapi3.jar file... adding c:\blp\api\apiv3\javaapi\v3.7.1.1\lib\blpapi3.jar java classpath bloomberg api version 3.7.1.1 > head(goog.bar) open high low close numevents volume 2014-07-10 13:30:00 565.910 566.85 565.01 565.745 142 38862 2014-07-10 13:31:00 565.500 566.06 565.01 565.190 49 7606 2014-07-10 13:32:00 565.110 566.70 565.11 566.350 49 6878 2014-07-10 13:33:00 566.390 566.60 566.00 566.600 34 4473 2014-07-10 13:34:00 566.470 566.48 565.65 565.850 52 6365 2014-07-10 13:35:00 565.775 566.45 565.55 566.050 107 14513 warning message: timezone of object (gmt) different current timezone (). > tail(goog.bar) open high low close numevents volume 2014-08-15 19:54:00 573.445 573.695 573.445 573.620 30 4428 2014-08-15 19:55:00 573.675 573.710 573.550 573.570 54 6496 2014-08-15 19:56:00 573.617 573.715 573.340 573.430 102 12067 2014-08-15 19:57:00 573.585 573.600 573.330 573.375 36 4300 2014-08-15 19:58:00 573.375 573.730 572.920 573.000 181 22467 2014-08-15 19:59:00 572.990 573.500 572.780 573.480 158 43183 warning message: timezone of object (gmt) different current timezone ().
Comments
Post a Comment