# Change periodicity on Rblpapi

So Dirk Eddelbuettel, Whit Armstrong, and John Laing released Rblpapi to CRAN recently, and it is awesome. I'm having some difficulty understanding how the overrides work though, hopefully someone can help me out.

I'm trying to import price returns from two indices, and want to do so using monthly data. W/out the periodicity override, it imports daily data fine. When I try and add an override to convert it to monthly data requests, I get an error. In the python api the override command is periodicity. Is it the same in Rblpapi? Does anyone know how this is this designed to work in Rblpapi? Are the override names and values the same as in the BBG developer's guide?

Here is a code sample and the resulting output:

library(Rblpapi)

#initalize data import
end.dt = Sys.Date()
start.dt = as.Date(x = "1995-03-31") #define start date

blpConnect() #connect to BBG, does not need to be closed

#set import variables
index.growth = "MXUS000G Index" #define growth index
index.value = "MXUS000V Index" #define value index

indices = c(index.growth,index.value)

overrides.px = "Monthly"
names(overrides.px) = "periodicity"

px = bdh(securities = indices,fields = "px_last",start.date = start.dt,end.date = end.dt,
overrides = overrides.px)



Thanks!

• I can replicate the error, must I have no idea what is wrong. Something in the returned information needs to be parsed differently. I have only had use for daily data so far... – Dirk Eddelbuettel Aug 18 '15 at 2:12

At first we considered it to be a bug where the overrides does not propagate correctly.

Edit: Here is a corrected examples, thanks to @Sid. Setting it as an options field works:

library(Rblpapi)
blpConnect()

## initalize data import
end.dt <- Sys.Date()
start.dt <- end.dt - 100  # keep it simple for example

index.growth <- "MXUS000G Index" #define growth index
index.value <- "MXUS000V Index" #define value index
indices <- c(index.growth,index.value)

overrides.px <- structure("MONTHLY", names=c"periodicitySelection")
px <- bdh(indices,"px_last",start.dt, end.dt, options = overrides.px)
print(px)


which works as you'd expect:

$r /tmp/periodicity.R$MXUS000G Index
date px_last
1 2015-05-29 3456.53
2 2015-06-30 3410.59
3 2015-07-31 3517.17

$MXUS000V Index date px_last 1 2015-05-29 2169.20 2 2015-06-30 2108.77 3 2015-07-31 2121.89$


(As an aside, we suggest to file bug reports etc over at GitHub. You got lucky that I saw this...)

• Thank you sir, this works perfectly. I cannot tell you how much I appreciate your work on this package, it really has made my week. In the future I'll post errors to Github, thanks! – JM Dorchuck Aug 18 '15 at 13:51
• My pleasure. We also get a lot of use out of it, and your report will make the documentation better. And please feel free to upvote or accept the answer. – Dirk Eddelbuettel Aug 18 '15 at 14:18

You're setting an option, not an override. Your code works fine if you replace

names(overrides.px) = "periodicity"
px = bdh(securities = indices,fields = "px_last",start.date = start.dt,end.date = end.dt,
overrides = overrides.px)


with

names(overrides.px) = "periodicitySelection"
px = bdh(securities = indices,fields = "px_last",start.date = start.dt,end.date = end.dt,
options = overrides.px)

• Indeed. Nice catch. – Dirk Eddelbuettel Aug 18 '15 at 10:08
• Excellent, thank you, @Sid.This solution works correctly. – JM Dorchuck Aug 18 '15 at 13:52