Skip to content
All library documents

Requesting Monthly Bloomberg Data with Rblpapi Options

Article Quant Q&A · Author: JM Dorchuck

Summary

This exchange explains how to request monthly historical prices for Bloomberg securities through Rblpapi. The key correction is that periodicity is a request option, not an override: set the option name to `periodicitySelection`, use the value `MONTHLY`, and pass it through the `options` argument to `bdh`.

The example retrieves monthly closing prices for two equity indices, with month-end observations in the output. The error arose from using the `overrides` argument and the name `periodicity`. This is a narrow API usage example; it does not discuss trading signals, data quality, Bloomberg entitlements, or other periodicity settings.

Key ideas

  • In Rblpapi, periodicity selection is passed as a request option rather than a field override.
  • The option name shown is `periodicitySelection`, with `MONTHLY` as its value.
  • The example retrieves monthly historical closing prices for two indices using `bdh`.

Tags

Full text
# Change periodicity on Rblpapi


# 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)

Error: Choice sub-element not found for name 'securityData'.
```

Thanks!

## Answer by Dirk Eddelbuettel (score 6, accepted)

https://quant.stackexchange.com/a/19368

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...)

## Answer by Sid (score 6)

https://quant.stackexchange.com/a/19371

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)
```

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.