Here’s an example R script that will login to Thomson Reuters, query for market price updates using Microsoft and Oracle symbols, and then loop forever, printing each update as it arrives.

    library("cdatafeedtre")
    Initialize()
    Login("*** ADD YOUR DACS ID HERE***")

    rics <- c("GOOG.O", "MSFT.O")

    #
    # Note that the serviceName defaults to "IDN_RDF" -- this can be set to a
    # different service name as appears below:
    #
    # Query(serviceName="dIDN_RDF", symbols=rics)
    #
    Query(symbols=rics)

    while (TRUE) {
        nextUpdate <- GetNextUpdate(timeout="120000")
        print(nextUpdate)
    }
    Logout()

That’s it!

Note that the timeout parameter is used to indicate the duration the R Gui will wait for an update to return in milliseconds — in the example above, this equates to two minutes. Keep in mind that if no timeout is declared the R Gui will wait forever for a result to be returned.

Once the timeout period has elapsed and no update has been issued, the package will return NULL — the user can check for NULL as follows:

    if (is.null (nextUpdate)) {/* handle null nextUpdate. */} else {/* handle non-null nextUpdate. */}

Java Documentation | Bitbucket

Leave a Reply