Documentation Center

  • Trial Software
  • Product Updates

realtime

Bloomberg V3 real-time data retrieval

Syntax

  • d = realtime(c,s,f) example
  • [subs,t] = realtime(...,eventhandler) example

Description

example

d = realtime(c,s,f) returns the data for the given connection c, security list s, and requested fields f.

example

[subs,t] = realtime(...,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.

Examples

expand all

Retrieve Data for One Security

Retrieve a snapshot of data for one security only.

Create the Bloomberg® connection.

c = blp;

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);

Retrieve Data for One Security Using the Event Handler v3stockticker

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;

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);

Retrieve Data for Multiple Securities Using the Event Handler v3stockticker

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;

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

v3stockticker requires the input argument f of realtime 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 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);

Retrieve Data for One Security Using the Event Handler v3showtrades

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;

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.

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

Close the Bloomberg connection.

close(c);

Retrieve Data for One Security Using the Event Handler v3pricevol

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;

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.

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

Close the Bloomberg connection.

close(c);

Input Arguments

expand all

c — Bloomberg connectionconnection object

Bloomberg connection, specified as a connection object created using blp.

s — Security liststring | cell array

Security list, specified as a string for one security or a cell 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

f — Bloomberg data fieldsstring | cell array

Bloomberg data fields, specified as a Bloomberg specific string for one data field or a cell array of Bloomberg specific strings for multiple data fields. For details about the strings 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

eventhandler — Event handlerstring

Event handler, specified as a string denoting 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

Output Arguments

expand all

d — Bloomberg return datastructure

Bloomberg return data, returned as a structure with the Bloomberg data. For details about the returned data, see the Bloomberg API Developer's Guide using the WAPI <GO> option from the Bloomberg terminal.

subs — Bloomberg subscriptionobject

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.

t — MATLAB timerobject

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

See Also

| | | |

Was this topic helpful?