Search code examples
rbloomberg

R: Extracting multiple bids from Bloomberg


I'm looking for a way to extract all the bids for multiple series over a certain time frame from Bloomberg using the Rbbg package.

My code currently looks like this:

bids = tick(conn, paste(colnames(prices), " SJ EQUITY",sep = ""), "BID", 
            "2013-11-05 07:00:00.000", "2013-11-05 14:50:00.000")

Where colnames(prices) are all the shares for which I'm trying to extract the bids.
But I get the following error:

Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl,  : 
  java.lang.NoSuchMethodException: No suitable method for the given parameters 

If I do it for one time series its fine, with the output as follows:

time      type  value   size  
2013-11-05T07:00:26.000 BID 26500   1000  
2013-11-05T07:00:26.000 BID 26500   1230  
2013-11-05T07:00:30.000 BID 26500   1347  
2013-11-05T07:00:31.000 BID 26500   1574  
2013-11-05T07:00:55.000 BID 26501   299

Sorry, I tried, but I don't know how to make the columns match up in the above output.

Any help would be greatly appreciated, as I've been stuck for quite some time.


Solution

  • Ok, so the following allows me to extract tick by tick bids/asks/trades from Bloomberg for multiple securities at once, where the columns of "prices" contains my share names:

      for (i in 1:length(prices))   {
        assign(paste("Bids_",colnames(prices)[i],sep=""),
               tick(conn, paste(colnames(prices)[i], " SJ EQUITY",sep=""), "BID", 
                    "2013-11-19 07:00:00.000", "2013-11-20 07:50:00.000"))
        assign(paste("Asks_",colnames(prices)[i],sep=""),
               tick(conn, paste(colnames(prices)[i], " SJ EQUITY",sep=""), "ASK", 
                    "2013-11-19 07:00:00.000", "2013-11-20 14:50:00.000"))
        assign(paste("Trades_",colnames(prices)[i],sep=""),
               tick(conn, paste(colnames(prices)[i], " SJ EQUITY",sep=""), "TRADE", 
                    "2013-11-19 07:00:00.000", "2013-11-20 14:50:00.000"))
    

    }

    This creates a 3 matrices for each of stock: one for the bids, one for asks and one for trades.

    Note though, you can only extract data from up to 60 days ago.