Retrieve Bloomberg Real-Time Data Using Bloomberg Server 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
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);
Validate the Bloomberg connection.
v = isconnection(c)
v = 1
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'}, ... {'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 Bloomberg Connection
close(c)
See Also
Objects
Functions
Related Examples
- Retrieve Bloomberg Current Data Using Bloomberg Server C++ Interface
- Retrieve Bloomberg Historical Data Using Bloomberg Server C++ Interface
- Retrieve Bloomberg Intraday Tick Data Using Bloomberg Server C++ Interface