realtime
Description
returns the data for the d
= realtime(c
,s
,f
)bloombergServer
object c
with the Bloomberg® Server C++ interface, security list s
, and requested fields
f
. realtime
accesses the Bloomberg Market Data service.
[~,
returns an empty output and the timer t
]
= realtime(c
,s
,f
,eventhandler
)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
Retrieve Data for One Security
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)
Retrieve Data for One Security Using Event Handler
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)
Retrieve Data for Multiple Securities Using Event Handler
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
c
— Bloomberg Server connection
bloombergServer
object
Bloomberg Server connection, specified as a bloombergServer
object.
s
— Security list
character vector | string scalar | cell array of character vectors | string array
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
f
— Bloomberg data fields
character vector | string scalar | cell array of character vectors | string array
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
eventhandler
— Event handler
character vector | string scalar
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
d
— Bloomberg data
structure (default) | table | timetable
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.
t
— MATLAB timer
object
MATLAB timer, returned as a MATLAB object. For details about this object, see timer
.
Version History
Introduced in R2021a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)