Closed Ddfulton closed 3 years ago
This might be a problem with the number of fields rather than the field itself. For me/on my computer, this seems to happen if the number of fields exceeds 25, independent of the choice of fields:
library(Rblpapi)
blpConnect()
flds_x <- c("RSRV_FOR_LOAN_LOSS_TO_TOT_LOAN", "BS_COMM_LOAN", "BS_CONS_LOAN",
"BS_TOT_ASSET", "ANN_NET_INT_MARGIN", "BS_CASH_NEAR_CASH_ITEM",
"COUNTRY_FULL_NAME", "NPLS_TO_TOTAL_LOANS",
"NPLS_TO_COMMON_EQUITY", "NPLS_TO_TOTAL_ASSETS", "PCT_WOMEN_MGT",
"PCT_WOMEN_EMPLOYEES", "EQY_FREE_FLOAT_PCT", "IS_PERSONNEL_EXP",
"PERSONNEL_EXPN_PER_EMPLOYEE", "PERSONNEL_EXPENSES_TO_NET_REV",
"AVG_EXECUTIVE_TOT_COMPENSATION", "NUM_OF_EMPLOYEES",
"BS_NET_FIX_ASSET", "BS_TOT_OTHER_PRPTY_AND_EQUIP",
"BS_CUSTOMER_DEPOSITS", "BS_LT_BORROW", "PX_TO_TANG_BV_PER_SH",
"PE_RATIO", "RETURN_COM_EQY")
length(flds_x)
#> [1] 25
# Works
df <- bdh("GLE FP Equity", flds_x, start.date=Sys.Date() - 10)
# Fails
df <- bdh("GLE FP Equity", c(flds_x, "PX_LAST"), start.date=Sys.Date() - 10)
#> Error in bdh_Impl(con, securities, fields, start.date, end.date, options, : Choice sub-element not found for name 'securityData'.
As a workaround, you can split bdh-fields and merge afterwards:
# Works
df1 <- bdh("GLE FP Equity", flds_x, start.date=Sys.Date() - 365, options=c("periodicitySelection"="QUARTERLY"))
df2 <- bdh("GLE FP Equity", "BS_TIER1_CAP_RATIO", start.date=Sys.Date() - 365, options=c("periodicitySelection"="QUARTERLY"))
df <- merge(df1, df2, by = "date", all = TRUE)
And to have a more easy reproducible example avoiding typing lots of fields:
library(Rblpapi)
blpConnect()
# works
df1 <- bdh("DAX Index", c(paste0("VAR_SWAP_", 1:24, "M_LV"), "PX_OPEN"), Sys.Date()-5)
# fails
df2 <- bdh("DAX Index", c(paste0("VAR_SWAP_", 1:24, "M_LV"), "PX_OPEN", "PX_LAST"), Sys.Date()-5)
#> Error in bdh_Impl(con, securities, fields, start.date, end.date, options, : Choice sub-element not found for name 'securityData'.
A limit of 25 would explain it, as I've had similar issues in the past. And that merge is perfect. Thank you very much for the help.
I have a list of fields I want, denoted
flds_x
in the code below. This works fine withbdh
. I also want the fieldBS_TIER1_CAP_RATIO
. So I added it toflds_x
. Then it breaks. But when I try to getBS_TIER1_CAP_RATIO
by itself, it works fine. I am essentially playing a guessing game where I add one more field toflds_x
at a time, and see whether it works or if it breaks. It usually breaks.When it breaks it throws the error:
Error in bdh_Impl(con, securities, fields, start.date, end.date, options, : Choice sub-element not found for name 'securityData'.
Reproducible example below