RE: [R] Bloomberg data import SOLVED

From: <>
Date: Fri 01 Apr 2005 - 07:14:26 EST

Together with Enrique's running start and Prasad's work, we figured out how to get tick data and bulk data from Bloomberg into R. Here is a code snippet which builds on Enrique's.


blCon <<- try(blCon <- COMCreate("Bloomberg.Data.1"), silent=TRUE)
# Always check the class of blCon before proceeding!

# First tick data

ticker <- "IBM US Equity"
fields <- c("Last Price","Volume")

comFrom <- new("COMDate",38442.4583333333) comTo <- new("COMDate",38442.58247696760) z <- as.integer(0)

histData <- try(blCon$BLPGetHistoricalData(Security=ticker, Fields=fields, StartDate=comFrom, EndDate=comTo, BarSize=z))

# Notes:
# Passing in just a 0 instead of an int 0 (as z) crashes Rgui
# For tick data, only one ticker is allowed in each call.
# Beware of asking for a long date range; tick data can be very
# I'm sure someone can do some R-magic to fix my start and end datetimes

# Bulk data is just like getting prices, except for the return object
being more complex
tickers <- c("TYM5 Comdty", "USM5 Comdty") fields <- c("FUT_DELIVERABLE_BONDS", "FUT_DLVRBLE_BNDS_CUSIPS") bulkData <- try(blCon$BlpSubscribe(Security=tickers, Fields=fields))

Note that my original idea about GetHistoricalData was wrong since that isn't a function. (At least I couldn't get it to work.)

As a last note, it would be very nice if RDCOMClient were directly available from CRAN so we could use install.packages, etc. (hint, hint!)

David L. Reiner

p.s. I know cross-posting is discouraged, but I thought some people might be looking for this information on r-sig-finance someday. mailing list PLEASE do read the posting guide! Received on Fri Apr 01 07:24:12 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:30:58 EST