Rblp / Rblpapi

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

bdh function: include.non.trading.days not working in conjunction with other options. #167

Open ghost opened 8 years ago

ghost commented 8 years ago

This issue pertains to attempting to pull historic data (bdh function) for all real days, and setting the way NA values are handled. This filling does work, when all options are set within the options argument, but does not work when some options are set in options and include.non.trading.days is used. Below is a simple example:

library(Rblpapi)

blpConnect()

# Print 30 real days of data, without backfilling missing values:
bdh("VIX Index", "PX_LAST", start.date = Sys.Date() - 30, include.non.trading.days = TRUE)

# Now, try to use the option to fill NA's with the previous value:
myOptions <- structure(c("PREVIOUS_VALUE"), names = c("nonTradingDayFillMethod"))

# You'll notice, all the NA's remain:
bdh("VIX Index", "PX_LAST", start.date = Sys.Date() - 30, include.non.trading.days = TRUE, options = myOptions)

# Instead of specifying 'include.non.trading.days' in the bdh function, I'll move this directly to the options:
myOptions <- structure(c("PREVIOUS_VALUE", "ALL_CALENDAR_DAYS"), names = c("nonTradingDayFillMethod", "nonTradingDayFillOption"))
# Then, I remove the 'include.non.trading.days' specification from the function, and it works as expected:
bdh("VIX Index", "PX_LAST", start.date = Sys.Date() - 30, options = myOptions)

This most likely ought to be low priority, since there is a fairly straight-forward work-around. Rather, this is more FYI.

eddelbuettel commented 8 years ago

Nice work. I will try to replicate.

I think this is a leftover from a 'version 1' of the interface, and I suggest to

Thoughts @armstrtw @johnlaing ?