lowlevel(RBloomberg)R Documentation

Low Level Functions

Description

These functions are not to be called by the user. This is ad-hoc documentation for developers of this package.

Usage

blpGetHistoricalData(conn, securities, fields, start, end, barsize = NULL,
                     barfields = NULL)
blpSubscribe(conn, securities, fields)
replaceBloombergErrors(x, suppress = TRUE)
dataType(mnemonic, bbfields = .bbfields)
## S3 method for class 'chron':
as.COMDate(x, date1904 = FALSE)
## S3 method for class 'COMDate':
as.chron(x, date1904 = FALSE, ...)
## S3 method for class 'BlpCOMReturn':
as.matrix(x)
## S3 method for class 'BlpCOMReturn':
as.data.frame(x, row.names = NULL, optional =
FALSE, ...)
## S3 method for class 'BlpCOMReturn':
as.zoo(x, suppress = TRUE, bbfields = .bbfields, ...)

Arguments

x object
conn connection object
securities vector of Bloomberg security codes
fields vector of field mnumonics
start,end chron object defining data window
barsize see blpGetData documentaion
barfields see blpGetData documentaion
date1904 see below
suppress logical. do not raise warnings when Bloomberg error codes are converted to NA's
mnemonic Bloomberg field mnemonic, as documented in bbfields
bbfields dataframe containing data in bbfields
row.names ignored
optional ignored
... other args

Details

At the moment this package can connect to Bloomberg only via the COM Desktop interface. Support for other Bloomberg interfaces are invisioned, especially the C Server interface.

The user interacts with Bloomberg via the blpGetData function. This is a generic and a method will eventually exist for each Bloomberg interface. The idea is that calls to it and the values returned by it are exactly the same, regardless of the actual interface used, which is determined by the class of the connection object passed to the first argument of blpGetData. In short: user code is devorced from choice of interface. That's the aim. Currently, only one method exists, blpGetData.BlpCOM.

All COM requests return a nested list, the nesting structure implicitly defining the return value's dimension and preserving data types. At present, we only support two-dimensional return values (e.g., a multiple security, mutiple field timeseries request is not allowed).

First, the nested list is transformed into something useful by coercing it to a vector, thereby implicitly coercing everything to the character data type if there is at least one non-numeric item in the return. If there are any Bloomberg error codes, these are then converted to NA's. Finally, the columns are recoved by setting the dim attribute based on what we know about the request. If the request is for a timeseries, the leftmost column is the COM date index, represented numerically. We use as.chron(mtx[1,]) to get back chron dates.

If there are multiple data types in a single return, a dataframe is the natural structure for Bloomberg return values. But how do we recover the data types? (Note: a single Bloomberg error code in a numeric field will cause that field to be coerced into character mode on the strategy implimented here.) When RBloomberg is attached, the .bbfields file on the user's workstation is read and stored as a dataframe in .bbfields on the workspace. Every field availiable from the Bloomberg API is mapped onto a datatype in this file. RBloomberg maps these datatypes to R datatypes. We use this information to recover datatypes when a data.frame is required.

blpGetHistoricalData and blpSubscribe are both wrappers to the COM methods of the same name. Depending on what is passed to blpGetHistoricalData, either a historical, intraday bars, or intraday tick request is made. blpSubscribe is for non-time series requests. Both functions return an object of class 'BlpCOMReturn', which is nothing more than the list returned by the COM method with some attributes attached. The attributes provide meta-information that the coercion methods need to coerce the nested list returned by COM.

Users pass chron dates to blpGetData and they always get chron dates. But COM requests expect COM dates and return COM dates, which are floating point reals representing the number of days since 1900. Two coercion functions as.Date.comDate and as.comDate.Date are provided to deal with this. For a discussion of the issue surrounding the treatment of 1904, see http://cpearson.com/excel/datetime.htm.

Author(s)

Robert Sams robert@sanctumfi.com

References

From your Bloomberg terminal, use function WAPI:
"BLPGetHistoricalData Property" Ref# FRP003
"History, Raw Tick and Time-Bar Requests" Ref# DP015
"Extended Historical Data Requests" Ref# DBExt
"Appendix C: Ticker Syntax" Ref# APX003
"Appendix D: Reading the Data Dictionary" Ref# CAX041
"Appendix G: Error Codes" Ref# APX007

Also, threads in the R-sig-finance mailing list archives:
"Import from Bloomberg" Enrique Bengoechea, 6 Jul 04
"Bloomberg data import" David L. Reiner, 31 Mar 05


[Package RBloomberg version 0.2-2 Index]