Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Retrieve Bloomberg Historical Data

This example shows how to retrieve historical data from Bloomberg® for a single security and for multiple securities. To create a successful Bloomberg connection, see Connect to Bloomberg.

Connect to Bloomberg

Create a Bloomberg Desktop connection.

c = blp;

Alternatively, you can connect to the Bloomberg Server using blpsrv or Bloomberg B-PIPE® using bpipe.

Retrieve Historical Data for One Security

Retrieve monthly closing and open price data from January 1, 2012, through December 31, 2012, for Microsoft®.

d contains the numeric representation of the date in the first column, closing price in the second column, and open price in the third column. Each row represents data for one month in the date range. sec contains the Bloomberg security name for Microsoft.

sec = 'MSFT US Equity';
fields = {'LAST_PRICE';'OPEN'}; % Retrieve data for closing and open prices
fromdate = '1/01/2012'; % Start of date range for historical data
todate = '12/31/2012'; % End of date range for historical data
period = 'monthly'; % Retrieve monthly data

[d,sec] = history(c,sec,fields,fromdate,todate,period)
d = 

     734899.00         27.87         25.06
     734928.00         30.16         28.12
     734959.00         30.65         30.34
     ...

sec =

  cell

    'MSFT US Equity'

Retrieve Historical Data for Multiple Securities

Retrieve monthly closing and open price data from January 1, 2012, through December 31, 2012, for the IBM® and Ford Motor Company® securities.

d is a cell array of double matrices that contains the historical data for both securities. sec contains the Bloomberg security names for the IBM and Ford Motor Company securities 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 closing and open prices
fromdate = '1/01/2012'; % Start of date range for historical data
todate = '12/31/2012'; % End of date range for historical data
period = 'monthly'; % Retrieve monthly data

[d,sec] = history(c,s,fields,fromdate,todate,period)
d =

  2×1 cell array

    [12×3 double]
    [12×3 double]


sec =

  2×1 cell array

    'IBM US Equity'
    'F US Equity'

Display the closing and open prices for the first security.

The data in the double matrix is:

  • First column — Numeric representation of the date

  • Second column — Closing price

  • Third column — Open price

Each row represents data for one month in the date range.

d{1}
ans =

     734899.00        192.60        186.73
     734928.00        196.73        193.21
     734959.00        208.65        197.23
     ...

Close Bloomberg Connection

close(c)

See Also

| |

Related Examples

More About

Was this topic helpful?