Reputation: 2312
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?
Upvotes: 0
Views: 144
Reputation: 1692
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
Upvotes: 0