-
Notifications
You must be signed in to change notification settings - Fork 75
Order of BDH output #139
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
Comments
This was previously discussed in another issue, and dismissed. Please search old issue before (effectively re-)reporting the same. |
Bloomberg provides a sequenceNumber value in each securityData element of the response. This represents the position of that returned security in the original array of requested securities. This could be used to construct a resultant data frame following the requested order. |
Interesting. PRs welcome. |
R> Rblpapi::bdh(securities = c("SPX Index", "CCMP Index"), fields = "PX_LAST", start.date = Sys.Date() - 10, end.date = Sys.Date() - 10, verbose=TRUE)
HistoricalDataResponse = {
securityData = {
security = "SPX Index"
eidData[] = {
}
sequenceNumber = 0
fieldExceptions[] = {
}
fieldData[] = {
fieldData = {
date = 2016-02-19
PX_LAST = 1917.780000
}
}
}
}
HistoricalDataResponse = {
securityData = {
security = "CCMP Index"
eidData[] = {
}
sequenceNumber = 1
fieldExceptions[] = {
}
fieldData[] = {
fieldData = {
date = 2016-02-19
PX_LAST = 4504.429000
}
}
}
}
$`SPX Index`
date PX_LAST
1 2016-02-19 1917.78
$`CCMP Index`
date PX_LAST
1 2016-02-19 4504.43
R> |
Seems messy to take care of auxiliary data fields but if somebody has an itch to scratch ... |
bds needs to be refactored eventually to use two passes, one to capture the fields (as bbg does not provide a schema or fieldInfo for bds requests), and one to populate the result using the full rank fieldspace (I hope that makes sense, I can elaborate if I explained that poorly). So, when that refactoring is done, we can capture the results into a vector by seqNumber which should map to the order of the user request. It's similar to what was done here: and a check to make sure we match the user request (in case of errors in the security vector, I didn't know how bbg would handle this) Anyway, this will be an easy fix in terms of the refactoring we need to do. |
I am using
bdh
to pull the closing prices of equity indexes. I have noticed that the output order does not correspond to the security order input in the function. For example:Interestingly the output is not the same order as the input:
(manually edited out BB price data)
I tried looking into the R and C++ code but I cannot seem to find where it goes wrong. It looks like it happens in the C++ implementation of
bdh_Impl
. Perhaps Rcpp just casts it as a list and then R reorganises?The text was updated successfully, but these errors were encountered: