Main Content

Retrieve Bloomberg Real-Time Data Using Bloomberg B-PIPE C++ Interface

This example shows how to retrieve real-time data from Bloomberg®. Here, to display Bloomberg stock tick data at the command line, use the event handler disp. Instead of the default event handler, you can create your own event handler function to process Bloomberg data.

Connect to Bloomberg

Create a Bloomberg B-PIPE® connection using the IP address of the machine running the Bloomberg B-PIPE process. This example uses the Bloomberg B-PIPE C++ interface and assumes the following:

  • The authentication is Windows® authentication when you set authtype to 'OS_LOGON'.

  • The application name is blank because you are not connecting to Bloomberg B-PIPE using an application.

  • The IP address for the machine running the Bloomberg B-PIPE process is ''.

  • The port number of the machine running the Bloomberg B-PIPE process is 8194.

c is a bloombergBPIPE object.

authtype = 'OS_LOGON';
appname = '';
ipaddress = {''};
port = 8194;

c = bloombergBPIPE(authtype,appname,ipaddress,port);

Validate the Bloomberg connection.

v = isconnection(c)
v =


v returns true showing that the Bloomberg connection is valid.

Retrieve Real-Time Data

Retrieve the last price and volume for IBM® and Ford Motor Company® securities.

[~,t] = realtime(c,{'IBM US Equity','F US Equity'}, ...
t = 

   Timer Object: timer-4

   Timer Settings
      ExecutionMode: fixedRate
             Period: 0.05
           BusyMode: drop
            Running: off

           TimerFcn: 1x5 cell array
           ErrorFcn: ''
           StartFcn: ''
            StopFcn: ''

Columns 1 through 6

    {'SecurityID' }    {'LAST_PRICE'}    {'SecurityID' }    {'VOLUME'  }    {'SecurityID'   }    {'LAST_PRICE'}
    {'F US Equity'}    {'8.960000'  }    {'F US Equity'}    {'13423731'}    {'IBM US Equity'}    {'118.490000'}

  Columns 7 through 8

    {'SecurityID'   }    {'VOLUME'}
    {'IBM US Equity'}    {'744066'}

realtime returns the MATLAB® timer object with its properties. Then, realtime returns the stock tick data for the IBM and Ford Motor Company securities with the last price and volume.

Stop the display of real-time data.


Close Bloomberg Connection


See Also



Related Examples

More About