Skip to content
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

return a named list for single security #281

Open
Courvoisier13 opened this issue Nov 7, 2018 · 4 comments
Open

return a named list for single security #281

Courvoisier13 opened this issue Nov 7, 2018 · 4 comments

Comments

@Courvoisier13
Copy link

Hi,
bdh (and the others probably) returns a dataframe when using 1 security and a named list when using more than 1. This is not very consistent and it would be better if it always returned a named list of dataframes with the name = the security even with 1 security. This would help when using bind_rows for example. It would avoid us having to make special cases for 1 security and creating the list manually.

> bdh(securities = "VOD LN Equity", fields = "PX_LAST", start.date = as.Date("2018-11-05"), end.date = as.Date("2018-11-07"))
        date PX_LAST
1 2018-11-05  150.40
2 2018-11-06  146.28
3 2018-11-07  146.36
> bdh(securities = c("VOD LN Equity", "LLOY LN Equity"), fields = "PX_LAST", start.date = as.Date("2018-11-05"), end.date = as.Date("2018-11-07"))
$`VOD LN Equity`
        date PX_LAST
1 2018-11-05  150.40
2 2018-11-06  146.28
3 2018-11-07  146.44

$`LLOY LN Equity`
        date PX_LAST
1 2018-11-05   58.57
2 2018-11-06   57.71
3 2018-11-07   58.40
@armstrtw
Copy link
Contributor

armstrtw commented Nov 7, 2018

I disagree, but am not opposed to adding an option to do what you want.

My thoughts are if you are requesting one security only, it’s an interactive use case, and is inconvenient to have to access the first element of a one element list.

However, it should be trivial to test an option to always return a list.

@eddelbuettel
Copy link
Member

Also, changing interfaces that many years in generally needs a really good reason.

@Courvoisier13
Copy link
Author

Courvoisier13 commented Nov 11, 2018

I understand about the interface change. I am having to modify the package or write a wrapper function around it, which decreases readability (when sharing).
Actually, what you'd really want is to return a dataframe with the names of the instrument as a field. Because my issue is really that. An option with the output like the getbars function would be very useful.

@Courvoisier13
Copy link
Author

Hi, I actually double checked and this is how it was done in version 3.6.2. In that version, bdh always returns a named list.

Rblpapi version 0.3.6.2 using Blpapi headers 3.8.18.1 and run-time 3.8.18.1.
Please respect the Bloomberg licensing agreement and terms of service.
opening a new BBG connection...

bdh(securities = "VOD LN Equity", fields = "PX_LAST", start.date = as.Date("2018-11-05"), end.date = as.Date("2018-11-07"))
$VOD LN Equity
date PX_LAST
1 2018-11-05 150.40
2 2018-11-06 146.28
3 2018-11-07 147.88

bdh(securities = c("VOD LN Equity", "LLOY LN Equity"), fields = "PX_LAST", start.date = as.Date("2018-11-05"), end.date = as.Date("2018-11-07"))
$VOD LN Equity
date PX_LAST
1 2018-11-05 150.40
2 2018-11-06 146.28
3 2018-11-07 147.88

$LLOY LN Equity
date PX_LAST
1 2018-11-05 58.57
2 2018-11-06 57.71
3 2018-11-07 58.25

@Rblp Rblp deleted a comment from entropy43 Nov 2, 2019
@Rblp Rblp locked and limited conversation to collaborators Nov 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants