getTicks {Rblpapi} | R Documentation |
Get Ticks from Bloomberg
Description
This function uses the Bloomberg API to retrieve ticks for the requested security.
Usage
getTicks(security, eventType = "TRADE", startTime = Sys.time() - 60 * 60,
endTime = Sys.time(), verbose = FALSE, returnAs = getOption("blpType",
"data.frame"), 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, default is ‘TRADE’. |
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 |
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 ‘data.frame’ (also the default), ‘data.table’, ‘xts’ and ‘zoo’ |
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 |
Value
Depending on the value of ‘returnAs’, either a ‘data.frame’ or ‘data.table’ object also containing non-numerical information such as condition codes, or a time-indexed container of type ‘xts’ and ‘zoo’ with a numeric matrix containing only ‘value’ and ‘size’.
Note
Bloomberg returns condition codes as well, and may return multiple observations for the same trade. Eg for ES we can get ‘AS’ or ‘AB’ for aggressor buy or sell, ‘OR’ for an order participating in the matching event, or a ‘TSUM’ trade summary. Note that this implies double-counting. There may be an option for this in the API.
The Bloomberg API allows to retrieve up to 140 days of intra-day history relative to the current date.
Author(s)
Dirk Eddelbuettel
Examples
## Not run:
res <- getTicks("ES1 Index")
str(res)
head(res, 20)
res <- getTicks("ES1 Index", returnAs="data.table")
str(res)
head(res, 20)
## End(Not run)