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

Error: Attempt to access value of element 'PX_VOLUME'(type: 'Float64') as 'Int32' type #207

Closed
jrehor opened this issue Dec 13, 2016 · 8 comments

Comments

@jrehor
Copy link

jrehor commented Dec 13, 2016

I believe this is related to #172 which has been fixed for 'VOLUME' but continues to fail with 'PX_VOLUME'.

The problem can be reproduced the same way in Rblpapi 0.3.5 on Windows:

opt <- c("periodicitySelection"="MONTHLY")
Rblpapi::bdh("SPY US Equity", c("PX_LAST", "PX_VOLUME"), start.date=Sys.Date()-31*6, options=opt)
@armstrtw
Copy link
Contributor

is this set? in your options?
https://github.com/Rblp/Rblpapi/blob/master/R/bdh.R#L78

@eddelbuettel
Copy link
Member

Please just use VOLUME. As you say, that works:

R> opt <- c("periodicitySelection"="MONTHLY")
R> bdh("SPY US Equity", c("PX_LAST", "PX_VOLUME"), start.date=Sys.Date()-31*6, options=opt)
Error in eval(substitute(expr), envir, enclos) : 
  Attempt to access value of element 'PX_VOLUME'(type: 'Float64') as 'Int32' type.
R> bdh("SPY US Equity", c("PX_LAST", "VOLUME"), start.date=Sys.Date()-31*6, options=opt)
        date PX_LAST     VOLUME
1 2016-06-30 209.475 2630619702
2 2016-07-29 217.120 1648381477
3 2016-08-31 217.380 1519703229
4 2016-09-30 216.300 2303701186
5 2016-10-31 212.550 1725687191
6 2016-11-30 220.380 2073824327
R> 

If you build from the current sources, you also get a new option:

R> opt <- c("periodicitySelection"="MONTHLY")
R> bdh("SPY US Equity", c("PX_LAST", "PX_VOLUME"), start.date=Sys.Date()-31*6, options=opt, int.as.double=TRUE)
        date PX_LAST  PX_VOLUME
1 2016-06-30 209.475 2630619702
2 2016-07-29 217.120 1648381477
3 2016-08-31 217.380 1519703229
4 2016-09-30 216.300 2303701186
5 2016-10-31 212.550 1725687191
6 2016-11-30 220.380 2073824327
R> 

@eddelbuettel
Copy link
Member

@armstrtw That option is not in the CRAN version 0.3.5. And I don't think we put a new binary into the drat repository.

@jrehor
Copy link
Author

jrehor commented Dec 13, 2016

Right. I'm going with VOLUME for now.

The 'int.as.double' option looks like a good solution.

@eddelbuettel
Copy link
Member

Would an interim (Windows) binary for the current GitHub code base help?

@jrehor
Copy link
Author

jrehor commented Dec 13, 2016

Wow, that would be wonderful. Thank you for considering it.

@eddelbuettel
Copy link
Member

I just pushed it to the ghrr drat. You should be able to get via

install.packages("drat")       # easier repo access + creation
drat:::add("ghrr")             # make it known
install.packages("Rblpapi")    # install it

and that should get you 0.3.5.1 which is ahead of CRAN by that very int.as.double option.

@jrehor
Copy link
Author

jrehor commented Dec 14, 2016

Thank you! I just confirmed that this solution works.

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

No branches or pull requests

3 participants