0

My code

library(Rblpapi)
library(purrr)
blpConnect()
tickers = c("AAPL US Equity", "VOD LN Equity")
adjustmentFactors = setNames({
  tickers %>% map(function(ticker){
    res = bds(
      security = ticker
      , field = "EQY_DVD_ADJUST_FACT"
      , overrides = c("CORPORATE_ACTIONS_FILTER"="ABNORMAL_CASH|CAPITAL_CHANGE|NORMAL_CASH")
    )
    message(ticker)
    res
  })
}, tickers)

This takes a long time to run because each call to bds is a separate request. Is there a way to package this up into a single request? Or maybe some other way of speeding it up?

Chechy Levas
  • 2,206
  • 1
  • 13
  • 28
  • Yes, you can request all of them at once and then combine the list. Could you please provide some of the tickers you are requesting and the libraries you are loading? I'll come up with an example. – tester Nov 05 '20 at 11:51
  • @tester - I have updated with better example code – Chechy Levas Nov 05 '20 at 11:59

1 Answers1

0

Sorry, I mesread your question a bit and thought it was a bdp or bdh call. As can be seen from the doucmentation of Rblpapi, bds only takes single tickers as an argument. Anyway, here's my approach:

tickers = c("AAPL US Equity", "VOD LN Equity", "BMW GY Equity")
get_bds <- function(x){
  bds(
    security = x
    , field = "EQY_DVD_ADJUST_FACT"
    , overrides = c("CORPORATE_ACTIONS_FILTER"="ABNORMAL_CASH|CAPITAL_CHANGE|NORMAL_CASH")
  )
}

test <- lapply(tickers, FUN = get_bds)
> head(test[[1]], 3)
  Adjustment Date Adjustment Factor Adjustment Factor Flag Adjustment Factor Operator Type
1      2020-11-06            1.0000                      1                               2
2      2020-08-31            4.0000                      3                               1
3      2020-08-07            0.9982                      1                               2
tester
  • 1,662
  • 1
  • 10
  • 16