Main Content

realtime

Real-time data for Bloomberg Server connection V3

Since R2021a

Description

d = realtime(c,s,f) returns the data for the bloombergServer object c with the Bloomberg® Server C++ interface, security list s, and requested fields f. realtime accesses the Bloomberg Market Data service.

example

[~,t] = realtime(c,s,f,eventhandler) returns an empty output and the timer t associated with the real-time event handler for the subscription list. Given connection c, the realtime function subscribes to a security or securities s and requests fields f, to update in real time while running an event handler eventhandler.

example

Examples

collapse all

Retrieve a snapshot of data for one security only.

Connect to the Bloomberg Server using the IP address of the machine running the Bloomberg Server. This example uses the Bloomberg Server C++ interface and assumes the following:

  • The Bloomberg UUID is 12345678.

  • The IP address for the machine running the Bloomberg Server is '111.11.11.111'.

c is a bloombergServer object.

uuid = 12345678;
ipaddress = '111.11.11.111';

c = bloombergServer(uuid,ipaddress);

Retrieve the last trade and volume of the IBM® security.

d = realtime(c,'IBM US Equity',{'Last_Trade','Volume'})
d = 

    LAST_TRADE: '181.76'
        VOLUME: '7277793'

Close the Bloomberg connection.

close(c)

You can create your own event handler function to process Bloomberg data. For this example, use the event handler disp that displays Bloomberg stock tick data at the command line.

Connect to the Bloomberg Server using the IP address of the machine running the Bloomberg Server. This example uses the Bloomberg Server C++ interface and assumes the following:

  • The Bloomberg UUID is 12345678.

  • The IP address for the machine running the Bloomberg Server is '111.11.11.111'.

c is a bloombergServer object.

uuid = 12345678;
ipaddress = '111.11.11.111';

c = bloombergServer(uuid,ipaddress);

Retrieve the last price and volume for the IBM security using the event handler disp.

[~,t] = realtime(c,'IBM US Equity',{'LAST_PRICE','VOLUME'}, ...
    'disp')
t = 


   Timer Object: timer-4

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

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

   Columns 1 through 4

    {'SecurityID'   }    {'LAST_PRICE'}    {'SecurityID'   }    {'VOLUME'}
    {'IBM US Equity'}    {'118.490000'}    {'IBM US Equity'}    {'744066'}
...

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

Stop the display of real-time data.

stop(t)
c.Session.stopSubscriptions

Close the Bloomberg connection.

close(c)

You can create your own event handler function to process Bloomberg data. For this example, use the event handler disp that returns Bloomberg stock tick data at the command line.

Connect to the Bloomberg Server using the IP address of the machine running the Bloomberg Server. This example uses the Bloomberg Server C++ interface and assumes the following:

  • The Bloomberg UUID is 12345678.

  • The IP address for the machine running the Bloomberg Server is '111.11.11.111'.

c is a bloombergServer object.

uuid = 12345678;
ipaddress = '111.11.11.111';

c = bloombergServer(uuid,ipaddress);

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

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


   Timer Object: timer-4

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

   Callbacks
           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.

stop(t)
c.Session.stopSubscriptions

Close the Bloomberg connection.

close(c)

Input Arguments

collapse all

Bloomberg Server connection, specified as a bloombergServer object.

Security list, specified as a character vector or string scalar for one security or a cell array of character vectors or string array for multiple securities. You can specify the security by name or by CUSIP, and with or without the pricing source.

Data Types: char | cell | string

Bloomberg data fields, specified as a character vector, string scalar, cell array of character vectors, or string array. A character vector or string denotes one Bloomberg data field name. A cell array of character vectors or string array denotes multiple Bloomberg data field names. For details about the fields you can specify, see the Bloomberg API Developer’s Guide using the WAPI <GO> option from the Bloomberg terminal.

Example: {'LAST_PRICE';'OPEN'}

Data Types: char | cell | string

Event handler, specified as a character vector or string scalar that denotes the name of an event handler function that you define. You can define an event handler function to process any type of real-time Bloomberg events. The specified event handler function runs every time the timer fires.

Data Types: char | string

Output Arguments

collapse all

Bloomberg data, returned as a structure, table, or timetable. The data type of the Bloomberg data depends on the DataReturnFormat and DatetimeType properties of the connection object. For details about the data, see the Bloomberg API Developer’s Guide using the WAPI <GO> option from the Bloomberg terminal.

MATLAB timer, returned as a MATLAB object. For details about this object, see timer.

Version History

Introduced in R2021a