getBars: Get Open/High/Low/Close/Volume Bars from Bloomberg

View source: R/getBars.R

getBarsR Documentation

Get Open/High/Low/Close/Volume Bars from Bloomberg

Description

This function uses the Bloomberg API to retrieve bars for the requested security.

Usage

getBars(security, eventType = "TRADE", barInterval = 60,
  startTime = Sys.time() - 60 * 60 * 6, endTime = Sys.time(),
  options = NULL, verbose = FALSE, returnAs = getOption("blpType",
  "matrix"), tz = Sys.getenv("TZ", unset = "UTC"),
  con = defaultConnection())

Arguments

security

A character variable describing a valid security ticker

eventType

A character variable describing an event type; default is ‘TRADE’

barInterval

A integer denoting the number of minutes for each bar

startTime

A Datetime object with the start time, defaults to one hour before current time

endTime

A Datetime object with the end time, defaults to current time

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.

verbose

A boolean indicating whether verbose operation is desired, defaults to ‘FALSE’

returnAs

A character variable describing the type of return object; currently supported are ‘matrix’ (also the default), ‘xts’, ‘zoo’ and ‘data.table’

tz

A character variable with the desired local timezone, defaulting to the value ‘TZ’ environment variable, and ‘UTC’ if unset

con

A connection object as created by a blpConnect call, and retrieved via the internal function defaultConnection.

Value

A numeric matrix with elements ‘time’ (as a ‘POSIXct’ object), ‘open’, ‘high’, ‘low’, ‘close’, ‘numEvents’, ‘volume’, ‘value’ or an object of the type selected in returnAs. Note that the ‘time’ value is adjusted: Bloomberg returns the opening time of the bar interval, whereas financial studies typically refer to the most recent timestamp. Therefore, if one wants the timestamp associated with the end of the bar interval one should add the length of the bar interval to time value returned from Bloomberg to obtain the time at the end of the interval.

Author(s)

Dirk Eddelbuettel

Examples

## Not run: 
  getBars("ES1 Index")

## End(Not run)

Rblpapi documentation built on Sept. 30, 2024, 5:08 p.m.