Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could you allow characters for `start.date` in `bdh()`? #266

Closed
DavisVaughan opened this Issue Jun 26, 2018 · 4 comments

Comments

Projects
None yet
2 participants
@DavisVaughan
Copy link
Contributor

DavisVaughan commented Jun 26, 2018

bdh() has a nice ability to determine the start date from a character string that doesn't correspond to a date (ex. start_date <- "-11CY"). While easily reproducible with R, it could generally be useful to let us use this feature. The only change needed is to remove or alter the check in the top level bdh() function on the start.date argument.

library(Rblpapi)
#> Warning: package 'Rblpapi' was built under R version 3.4.4
#> Rblpapi version 0.3.8 using Blpapi headers 3.8.18.1 and run-time 3.8.18.1.
#> Please respect the Bloomberg licensing agreement and terms of service.
blpConnect()

security <- "CPI XYOY Index"
field    <- "PX_LAST"
start_date <- "-11CY"

cpi_xyoy_index <- bdh(security, field, start.date = start_date)
#> Error: start.date must be a Date object


con <- defaultConnection()

res <- Rblpapi:::bdh_Impl(
  con, security, field, 
  start_date_ = start_date, end_date_ = NULL, 
  options_ = NULL, overrides_ = NULL, verbose = FALSE, 
  identity_ = NULL, int_as_double =  FALSE
)

head(res[[1]])
#>         date PX_LAST
#> 1 2006-12-31     2.6
#> 2 2007-01-31     2.7
#> 3 2007-02-28     2.7
#> 4 2007-03-31     2.5
#> 5 2007-04-30     2.3
#> 6 2007-05-31     2.2

Created on 2018-06-26 by the reprex package (v0.2.0).

@johnlaing

This comment has been minimized.

Copy link
Contributor

johnlaing commented Jun 26, 2018

Interesting! I didn't know about this feature. Should be a very easy patch.

@DavisVaughan

This comment has been minimized.

Copy link
Contributor Author

DavisVaughan commented Jun 26, 2018

Thanks so much!

johnlaing added a commit that referenced this issue Jun 26, 2018

@johnlaing

This comment has been minimized.

Copy link
Contributor

johnlaing commented Jun 28, 2018

@DavisVaughan give this a try when you have a chance.

@DavisVaughan

This comment has been minimized.

Copy link
Contributor Author

DavisVaughan commented Jul 14, 2018

Sorry on the delay. Won't be able to test easily as I can't install from github at work. But the change looks correct to me and as shown above it definitely works if you bypass bdh and drop straight into bdh_Impl so I think we are good to go. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.