bdh: Run 'Bloomberg Data History' Queries

Description Usage Arguments Value Author(s) See Also Examples

View source: R/bdh.R

Description

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

Usage

1
2
3
4
bdh(securities, fields, start.date, end.date = NULL,
  include.non.trading.days = FALSE, options = NULL, overrides = NULL,
  verbose = FALSE, identity = NULL, con = defaultConnection(),
  int.as.double = getOption("blpIntAsDouble", FALSE))

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.

int.as.double

A boolean indicating whether integer fields should be retrieved as doubles instead. This option is a workaround for very large values which would overflow int32. Defaults to ‘FALSE’

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.

Author(s)

Whit Armstrong and Dirk Eddelbuettel

See Also

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
## 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)

Rblpapi documentation built on Jan. 22, 2018, 1:04 a.m.