Main Content

RetrieveBloombergCurrent Data

This example shows how to retrieve current data from Bloomberg®为一个security and for multiple securities. To create a successful Bloomberg connection, seeConnect to Bloomberg.

Connect toBloomberg

Create a Bloomberg Desktop connection.

c = blp;

Alternatively, you can connect to the Bloomberg Server usingblpsrvor Bloomberg B-PIPE®usingbpipe.

Retrieve Current Data for Single Security

Retrieve last and open prices for Microsoft®.

dcontains the Bloomberg last and open prices as fields in a structure.seccontains the Bloomberg security name for Microsoft in a cell array. The security name is a character vector.

sec ='MSFT US Equity'; fields = {'LAST_PRICE';'OPEN'};% Retrieve data for last and open prices[d,sec] = getdata(c,sec,fields)
d = struct with fields: LAST_PRICE: 62.30 OPEN: 62.95 sec = cell 'MSFT US Equity'

Retrieve Current Data for Multiple Securities

Retrieve last and open prices for the IBM®and Ford Motor Company®securities.

dcontains the Bloomberg last and open prices as fields in a structure.seccontains the Bloomberg security names for IBM and Ford Motor Company in a cell array. Each security name is a character vector.

s = {'IBM US Equity','F US Equity'}; fields = {'LAST_PRICE';'OPEN'};% Retrieve data for last and open prices[d,sec] = getdata(c,s,fields)
d = struct with fields: LAST_PRICE: [2×1 double] OPEN: [2×1 double] sec = 2×1 cell array 'IBM US Equity' 'F US Equity'

Display the last price for both securities.

d.LAST_PRICE
ans = 166.73 12.63

CloseBloombergConnection

close(c)

See Also

||

Related Examples

More About