Rblp / Rblpapi

R package interfacing the Bloomberg API from https://www.bloomberglabs.com/api/
Other
167 stars 75 forks source link

VWAP_VOLUME request does not return the same results as in Excel #358

Closed travis-leith closed 2 years ago

travis-leith commented 2 years ago

For the following variations, I get no result

> bdp("AMS LN Equity","VWAP_VOLUME", overrides = c(VWAP_START_DT = "20210101", VWAP_END_DT = "20210101"))
              VWAP_VOLUME
AMS LN Equity          NA
> bdp("AMS LN Equity","VWAP_VOLUME", overrides = c(VWAP_START_DT = "2021-01-01", VWAP_END_DT = "2021-01-01"))
              VWAP_VOLUME
AMS LN Equity          NA
> bdp("AMS LN Equity","VWAP_VOLUME", overrides = c(VWAP_START_DT = as.Date("2021-01-01"), VWAP_END_DT = as.Date("2021-01-01")))
              VWAP_VOLUME
AMS LN Equity          NA

But in Excel, I get a result

image

I can do what I need to get done in Excel, but I thought I'd report the discrepancy here.

armstrtw commented 2 years ago

Looks like you are passing in new year's day to bdp, but the 12th in excel.

mtkerbeR commented 2 years ago

Correcting for the date, the code works as expected:

library(Rblpapi)
blpConnect()

bdp("AMS LN Equity","VWAP_VOLUME", overrides = c(VWAP_START_DT = "20211201", VWAP_END_DT = "20211201"))
#>               VWAP_VOLUME
#> AMS LN Equity      120502
eddelbuettel commented 2 years ago

Some of this code is old. I have since written code where I use anytime::anydate to reliably go from a text of date in just about any format to a Date object. (And that use case was one of the motivations for anytime as I got tired of having to spec dates when most people automagically write something close enough to ISO 8601 standards....

We could do the same here at the cost of an added dependency (or use a helper function shadowing that idea if we like the approach but hate the dependency).

travis-leith commented 2 years ago

sorry about this, silly mistake on my part.

eddelbuettel commented 2 years ago

No worries, stuff happens. We all have overlooked a bad option setting here or there before.