Learn R Programming

Rblpapi (version 0.3.5)

bdh: Run 'Bloomberg Data History' Queries

Description

This function uses the Bloomberg API to retrieve 'bdh' (Bloomberg Data History) queries

Usage

bdh(securities, fields, start.date, end.date = NULL, include.non.trading.days = FALSE, options = NULL, overrides = NULL, verbose = FALSE, identity = NULL, con = defaultConnection())

Arguments

securities
A character vector with security symbols in Bloomberg notation.
fields
A character vector with Bloomberg query fields.
start.date
A Date variable with the query start date.
end.date
An optional Date variable with the query end date; if omitted the most recent available date is used.
include.non.trading.days
An optional logical variable indicating whether non-trading days should be included.
options
An optional named character vector with option values. Each field must have both a name (designating the option being set) as well as a value.
overrides
An optional named character vector with override values. Each field must have both a name (designating the override being set) as well as a value.
verbose
A boolean indicating whether verbose operation is desired, defaults to ‘FALSE’
identity
An optional identity object.
con
A connection object as created by a blpConnect call, and retrieved via the internal function defaultConnection.

Value

A list with as a many entries as there are entries in securities; each list contains a data.frame with one row per observations and as many columns as entries in fields. If the list is of length one, it is collapsed into a single data frame. Note that the order of securities returned is determined by the backend and may be different from the order of securities in the securities field.

See Also

For historical futures series, see ‘DOCS #2072138 ’ on the Bloomberg terminal about selecting different rolling conventions.

Examples

Run this code
## Not run: 
#   bdh("SPY US Equity", c("PX_LAST", "VOLUME"), start.date=Sys.Date()-31)
# 
#   ## example for an options field: request monthly data; see section A.2.4 of
#   ##  http://www.bloomberglabs.com/content/uploads/sites/2/2014/07/blpapi-developers-guide-2.54.pdf
#   ## for more
#   opt <- c("periodicitySelection"="MONTHLY")
#   bdh("SPY US Equity", c("PX_LAST", "VOLUME"),
#       start.date=Sys.Date()-31*6, options=opt)
# 
#   ## example for options and overrides
#   opt <- c("periodicitySelection" = "QUARTERLY")
#   ovrd <- c("BEST_FPERIOD_OVERRIDE"="1GQ")
#   bdh("IBM US Equity", "BEST_SALES", start.date=Sys.Date()-365.25*4,
#       options=opt, overrides=ovrd)
# ## End(Not run)

Run the code above in your browser using DataLab