Main Content

RetrieveBloombergReal-Time Data UsingBloombergServer 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 handlerdisp. Instead of the default event handler, you can create your own event handler function to process Bloomberg data.

Connect toBloomberg

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

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

cis abloombergServerobject.

uuid = 12345678; ipaddress ='111.11.11.111'; c = bloombergServer(uuid,ipaddress);

弗吉尼亚州lidate the Bloomberg connection.

v = isconnection(c)
v = 1

vreturnstrue显示,布隆伯格连接是有效的。

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'} ...

realtimereturns the MATLAB®timer object with its properties. Then,realtimereturns 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

CloseBloombergConnection

close(c)

See Also

Objects

Functions

Related Examples

More About