Main Content

realtime

Real-time data for Bloomberg connection V3

Description

d = realtime(c,s,f) returns the data for the given connection c, security list s, and requested fields f. realtime accesses the Bloomberg® Market Data service.

example

[subs,t] = realtime(c,s,f,eventhandler) returns the subscription list subs 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.

Create the Bloomberg connection.

c = blp;

Alternatively, you can connect to the Bloomberg Server using blpsrv or Bloomberg B-PIPE® using bpipe.

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 v3stockticker that returns Bloomberg stock tick data.

Create the Bloomberg connection.

c = blp;

Alternatively, you can connect to the Bloomberg Server using blpsrv or Bloomberg B-PIPE using bpipe.

Retrieve the last trade and volume for the IBM security using the event handler v3stockticker.

v3stockticker requires the input argument f of realtime to be 'Last_Trade' , 'Volume', or both.

[subs,t] = realtime(c,'IBM US Equity',{'Last_Trade','Volume'},...
                    'v3stockticker')
subs =
 
com.bloomberglp.blpapi.SubscriptionList@79f07684
 
   Timer Object: timer-2

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

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

** IBM US Equity ** 100 @ 181.81 29-Oct-2013 15:48:50
** IBM US Equity ** 100 @ 181.795 29-Oct-2013 15:48:50
** IBM US Equity ** 100 @ 181.8065 29-Oct-2013 15:48:51
...

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

Real-time data continues to display until you execute the stop or close function.

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 v3stockticker that returns Bloomberg stock tick data.

Create the Bloomberg connection.

c = blp;

Alternatively, you can connect to the Bloomberg Server using blpsrv or Bloomberg B-PIPE using bpipe.

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

v3stockticker requires the input argument f of the realtime function to be 'Last_Trade', 'Volume', or both.

[subs,t] = realtime(c,{'IBM US Equity','F US Equity'}, ...
                    {'Last_Trade','Volume'},'v3stockticker')
subs =
 
com.bloomberglp.blpapi.SubscriptionList@6c1066f6
 

   Timer Object: timer-3

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

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

** IBM US Equity ** 32433 @ 181.85 29-Oct-2013 15:50:05
** IBM US Equity ** 200 @ 181.85 29-Oct-2013 15:50:05
** IBM US Equity ** 100 @ 181.86 29-Oct-2013 15:50:05
** F US Equity ** 300 @ 17.575 30-Oct-2013 10:14:06
** F US Equity ** 100 @ 17.57 30-Oct-2013 10:14:06
** F US Equity ** 100 @ 17.5725 30-Oct-2013 10:14:06
...

realtime returns the Bloomberg subscription list object subs and 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 trade price and volume.

Real-time data continues to display until you use the stop or close function.

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 v3showtrades that creates a figure showing requested data for a security.

Create the Bloomberg connection.

c = blp;

Alternatively, you can connect to the Bloomberg Server using blpsrv or Bloomberg B-PIPE using bpipe.

Retrieve volume, last trade, bid, ask, and volume weight adjusted price (VWAP) data for the IBM security using the event handler v3showtrades.

v3showtrades requires the input argument f of realtime to be any combination of: 'Last_Trade', 'Bid', 'Ask', 'Volume', and 'VWAP'.

[subs,t] = realtime(c,'IBM US Equity',...
                    {'Last_Trade','Bid','Ask','Volume','VWAP'},...
                    'v3showtrades')
subs =
 
com.bloomberglp.blpapi.SubscriptionList@5c17dcdb
 

   Timer Object: timer-4

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

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

realtime returns the Bloomberg subscription list object subs and the MATLAB timer object with its properties. Then, v3showtrades displays a figure showing volume, last trade, bid, ask, and volume weight adjusted price (VWAP) data for IBM.

V3 Show Trades Demo figure displays real-time price data for IBM stock.

Real-time data continues to display until you execute the stop or close function.

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 v3pricevol that creates a figure showing last price and volume data for a security.

Create the Bloomberg connection.

c = blp;

Alternatively, you can connect to the Bloomberg Server using blpsrv or Bloomberg B-PIPE using bpipe.

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

v3pricevol requires the input argument f of realtime to be 'Last_Price' , 'Volume', or both.

[subs,t] = realtime(c,'IBM US Equity',{'Last_Price','Volume'},...
                    'v3pricevol')
subs =
 
com.bloomberglp.blpapi.SubscriptionList@16f66676
 

   Timer Object: timer-5

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

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

realtime returns the Bloomberg subscription list object subs and the MATLAB timer object with its properties. Then, v3pricevol displays a figure showing last price and volume data for IBM.

V3 Price Volume Demo figure displays two plots with real-time data. The first plot shows the last price data for IBM stock. The second plot shows the volume data for IBM stock.

Real-time data continues to display until you execute the stop or close function.

Close the Bloomberg connection.

close(c)

Input Arguments

collapse all

Bloomberg connection, specified as a connection object created using blp, blpsrv, or bpipe.

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.

Bloomberg subscription, returned as a Bloomberg object. For details about this object, 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 R2010a