8000 Order of BDH output · Issue #139 · Rblp/Rblpapi · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

Closed
madcowgoatsmuggla opened this issue Feb 29, 2016 · 8 comments
Closed

Order of BDH output #139

madcowgoatsmuggla opened this issue Feb 29, 2016 · 8 comments

Comments

@madcowgoatsmuggla
Copy link

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:

Rblpapi::bdh(securities = c("SPX Index", "CCMP Index", "UKX Index", "DAX Index", 
                            "TPX Index", "SPTSX Index", "CAC Index", "INDU Index", 
                            "HSI Index", "SX5E Index"),
             fields = "PX_LAST", start.date = Sys.Date() - 10, end.date = Sys.Date() - 10)

Interestingly the output is not the same order as the input:

$`SPX Index`
        date PX_LAST
1 2016-02-19 1xxxx

$`HSI Index`
        date PX_LAST
1 2016-02-19 1xxxx

$`SX5E Index`
        date PX_LAST
1 2016-02-19 2xxxx

$`CCMP Index`
        date  PX_LAST
1 2016-02-19 4xxxx

$`UKX Index`
        date PX_LAST
1 2016-02-19 5xxxx

$`DAX Index`
        date PX_LAST
1 2016-02-19 9xxxx

$`TPX Index`
        date PX_LAST
1 2016-02-19 1xxxx

$`SPTSX Index`
        date PX_LAST
1 2016-02-19 1xxxx

$`CAC Index`
        date PX_LAST
1 2016-02-19 4xxxx

$`INDU Index`
        date  PX_LAST
1 2016-02-19 1xxxx

(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?

@eddelbuettel
Copy link
Member

This was previously discussed in another issue, and dismissed.

Please search old issue before (effectively re-)reporting the same.

@pgarnry
Copy link
pgarnry commented Feb 29, 2016

@madcowgoatsmuggla see #101

@eddelbuettel
Copy link
Member

Thanks for adding the reference, @PARNY. In essence, the story is that we 'merely' give back to you what we get from Bloomberg. We never promise a particularly sorted order.

I just added a word on that in commit 649be35 which expands the help page ever so slightly.

@wmorgan85
Copy link
Contributor

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.

@eddelbuettel
Copy link
Member

Interesting. PRs welcome.

@eddelbuettel
Copy link
Member 8000
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> 

@eddelbuettel
Copy link
Member

Seems messy to take care of auxiliary data fields but if somebody has an itch to scratch ...

@armstrtw
Copy link
Contributor

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:
https://github.com/Rblp/Rblpapi/blob/master/src/bdp.cpp#L62

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)
https://github.com/Rblp/Rblpapi/blob/master/src/bdp.cpp#L65

Anyway, this will be an easy fix in terms of the refactoring we need to do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
450C
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants
0