getBars | R Documentation |
This function uses the Bloomberg API to retrieve bars for the requested security.
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())
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 |
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.
Dirk Eddelbuettel
## Not run:
getBars("ES1 Index")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.