Categories
Coding Finance R

R/Reuters Real-Time Data Extension

Last week, I posted an R extension DLL that downloads historical data from Reuters using the SFC API. This time around, I am posting an extension DLL that can subscribe to real-time updates using the RFA API. This extension allows you to specify a list of items and data fields, and subscribe for a specified amount of time to updates on those items.

Here is an example:

# Load the DLL
dyn.load("RfaClient")

# Low-level subscription function wrapper
rsub < - function(time, items, func, sessionName, config, debug) { .Call("subscribe", as.integer(time), items, func , sessionName, config, debug) } # Define items and fields to subscribe to items <- list() fields <- c("BID","ASK","TIMCOR") items[[1]] <- c("IDN_SELECTFEED", "GBP=", fields) items[[2]] <- c("IDN_SELECTFEED", "JPY=", fields) # Callback function (invoked when data items update) callback <- function(df) { print(paste("Received an update for",df$ITEM, ", update time=", df$TIMCOR)) } # Subscribe for 5 seconds using the supplied config parameters rsub(5000, items, callback, "clientSession", "rfa.cfg", FALSE)

A short introductory guide is supplied:

Introduction (PDF)
Introduction (PDF)

The functionality is pretty basic right now, and there may be issues with the code (e.g. memory leaks, performance issues). Any feedback is gratefully received.

The package, including source, can be downloaded here:

rfaclient.zip

It was built with R 2.8.0 and RFA C++ 6.0.2, using Visual C++ 2005.