Rblp / Rblpapi

R package interfacing the Bloomberg API from https://www.bloomberglabs.com/api/
Other
166 stars 75 forks source link

bdp - Bulk Data #304

Closed skiamu closed 4 years ago

skiamu commented 4 years ago

Hi, is there a way to make the function bdp return bulk data? here's my code:

library(Rblpapi)
blpConnect()
ticker <- "KORS UN Equity"
ovr <- c(HISTORICAL_ID_TM_RANGE_START_DT='20100105')
w <- bdp(securities = ticker, fields = "HISTORICAL_IDS_TIME_RANGE")

it raises the following error:

Error in bdp_Impl(con, securities, fields, options, overrides, verbose,  : 
  Attempt to access value of element 'HISTORICAL_IDS_TIME_RANGE'(type: 'HISTORICAL_IDS_TIME_RANGE') as 'String' type.

Therefore, I tried

ovr <- c(HISTORICAL_ID_TM_RANGE_START_DT=as.Date("2010-01-05"))
w <- bdp(securities = ticker, fields = "HISTORICAL_IDS_TIME_RANGE", overrides = ovr)

but it returns an empty data.frame.

The data i'm expecting is this image

Thanks for your help

eddelbuettel commented 4 years ago

Guessing here but is it possible you'd want bdh() rather than bdp() ?

skiamu commented 4 years ago

First of all thank you for you answer.

I tried that as well

library(Rblpapi)
blpConnect()
ticker <- "KORS UN Equity"
ovr <- c(HISTORICAL_ID_TM_RANGE_START_DT='20100105')
w <- bdh(securities = ticker, fields = "HISTORICAL_IDS_TIME_RANGE",
         overrides = ovr,
         start.date = as.Date("2010-05-05")) # must specify a start.date

> w
[1] date                      HISTORICAL_IDS_TIME_RANGE
<0 rows> (or 0-length row.names)

The result is always and empty data.frame

johnlaing commented 4 years ago

Can you try with verbose=TRUE? That might shed some light

skiamu commented 4 years ago

Here's the code and the result

library(Rblpapi)
blpConnect()
ticker <- "KORS UN Equity"
ovr <- c(HISTORICAL_ID_TM_RANGE_START_DT='20100105')
w <- bdh(securities = ticker, fields = "HISTORICAL_IDS_TIME_RANGE",
         overrides = ovr,
         start.date = as.Date("2010-05-05"),
         verbose = TRUE)
HistoricalDataResponse = {
    securityData = {
        security = "KORS UN Equity"
        eidData[] = {
        }
        sequenceNumber = 0
        fieldExceptions[] = {
            fieldExceptions = {
                fieldId = "HISTORICAL_IDS_TIME_RANGE"
                errorInfo = {
                    source = "3890::bbdbh1"
                    code = 1
                    category = "BAD_FLD"
                    message = "Not valid historical field"
                    subcategory = "NOT_APPLICABLE_TO_HIST_DATA"
                }
            }
        }
        fieldData[] = {
        }
    }
}

The same happens also if I set overrides to NULL.

Just to give you some context: if I use bdp with a similar field (e.g. fields = "HISTORICAL_ID_POINT_TIME") it works:

library(Rblpapi)
blpConnect()
ticker <- "KORS UN Equity"
ovr <- c(HISTORICAL_ID_TM_RANGE_START_DT='20100105')
bdp(securities = ticker, fields = "HISTORICAL_ID_POINT_TIME", overrides = ovr)
               HISTORICAL_ID_POINT_TIME
KORS UN Equity                  CPRI US

I want to use HISTORICAL_IDS_TIME_RANGE because it gives you all the historical evolution and not just the current ticker

johnlaing commented 4 years ago

Maybe bds then?

skiamu commented 4 years ago

oh yes, that worked! thanks

johnlaing commented 4 years ago

Great!