Main Content

history

Historical data for Bloomberg B-PIPE connection V3

Since R2021a

Description

example

d = history(c,s,f,fromdate,todate) returns the historical data for the security list s for the fields f for the dates fromdate through todate using the bloombergBPIPE object c with the Bloomberg® B-PIPE® C++ interface. Date strings can be input in any format recognized by MATLAB®. sec is the security list that maps the order of the return data. The return data d is sorted to match the input order of s.

example

d = history(c,s,f,fromdate,todate,period) returns the historical data for the fields f and the dates fromdate through todate with a specific periodicity period.

example

d = history(c,s,f,fromdate,todate,period,currency) returns the historical data for the security list s for the fields f and the dates fromdate through todate based on the given currency currency.

example

d = history(c,s,f,fromdate,todate,period,currency,Name,Value) returns the historical data for the security list s using additional options specified by one or more name-value pair arguments.

example

[d,sec] = history(___) additionally returns the security list sec using any of the input argument combinations in the previous syntaxes. The return data, d and sec, are sorted to match the input order of s.

Examples

collapse all

First, create a Bloomberg Desktop connection. Then, retrieve the daily closing price for a security within a date range.

Create a Bloomberg B-PIPE connection using the IP address of the machine running the Bloomberg B-PIPE process. This example uses the Bloomberg B-PIPE C++ interface and assumes the following:

  • The authentication is Windows® authentication when you set authtype to 'OS_LOGON'.

  • The application name is blank because you are not connecting to Bloomberg B-PIPE using an application.

  • The IP address for the machine running the Bloomberg B-PIPE process is '111.11.11.112'.

  • The port number of the machine running the Bloomberg B-PIPE process is 8194.

c is a bloombergBPIPE object.

authtype = 'OS_LOGON';
appname = '';
ipaddress = {'111.11.11.112'};
port = 8194;

c = bloombergBPIPE(authtype,appname,ipaddress,port);

Get the daily closing price from August 1, 2010, through August 10, 2010, for the IBM® security.

[d,sec] = history(c,'IBM US Equity','LAST_PRICE',...
                  '8/01/2010','8/10/2010')
d =

     734352.00        123.55
     734353.00        123.18
     734354.00        124.03
     734355.00        124.56
     734356.00        123.58
     734359.00        125.34
     734360.00        125.19


sec = 

    'IBM US Equity'

d contains the numeric representation for the date in the first column and the closing price in the second column. sec contains the name of the IBM security.

Close the Bloomberg connection.

close(c)

First, create a Bloomberg Desktop connection. Then, retrieve the monthly closing prices for a security within a date range.

Create a Bloomberg B-PIPE connection using the IP address of the machine running the Bloomberg B-PIPE process. This example uses the Bloomberg B-PIPE C++ interface and assumes the following:

  • The authentication is Windows authentication when you set authtype to 'OS_LOGON'.

  • The application name is blank because you are not connecting to Bloomberg B-PIPE using an application.

  • The IP address for the machine running the Bloomberg B-PIPE process is '111.11.11.112'.

  • The port number of the machine running the Bloomberg B-PIPE process is 8194.

c is a bloombergBPIPE object.

authtype = 'OS_LOGON';
appname = '';
ipaddress = {'111.11.11.112'};
port = 8194;

c = bloombergBPIPE(authtype,appname,ipaddress,port);

Get the monthly closing price from August 1, 2010, through December 10, 2010, for the IBM security.

[d,sec] = history(c,'IBM US Equity','LAST_PRICE',...
                  '8/01/2010','12/10/2010','monthly')
d =

     734360.00        125.19
     734391.00        121.53
     734421.00        131.85
     734452.00        139.78
     734482.00        138.13


sec = 

    'IBM US Equity'

d contains the numeric representation for the date in the first column and the closing price in the second column. sec contains the name of the IBM security.

Close the Bloomberg connection.

close(c)

First, create a Bloomberg Desktop connection. Then, retrieve the monthly closing prices for a security within a date range. Specify prices using the US currency.

Create a Bloomberg B-PIPE connection using the IP address of the machine running the Bloomberg B-PIPE process. This example uses the Bloomberg B-PIPE C++ interface and assumes the following:

  • The authentication is Windows authentication when you set authtype to 'OS_LOGON'.

  • The application name is blank because you are not connecting to Bloomberg B-PIPE using an application.

  • The IP address for the machine running the Bloomberg B-PIPE process is '111.11.11.112'.

  • The port number of the machine running the Bloomberg B-PIPE process is 8194.

c is a bloombergBPIPE object.

authtype = 'OS_LOGON';
appname = '';
ipaddress = {'111.11.11.112'};
port = 8194;

c = bloombergBPIPE(authtype,appname,ipaddress,port);

Get the monthly closing price from August 1, 2010, through December 10, 2010, for the IBM security in US currency 'USD'.

[d,sec] = history(c,'IBM US Equity','LAST_PRICE',...
                  '8/01/2010','12/10/2010','monthly','USD')
d =

     734360.00        125.19
     734391.00        121.53
     734421.00        131.85
     734452.00        139.78
     734482.00        138.13


sec = 

    'IBM US Equity'

d contains the numeric representation for the date in the first column and the closing price in the second column. sec contains the name of the IBM security.

Close the Bloomberg connection.

close(c)

First, create a Bloomberg Desktop connection. Then, retrieve the monthly closing prices for a security within a date range. Specify prices using the US currency. Specify period values to customize the returned data.

Create a Bloomberg B-PIPE connection using the IP address of the machine running the Bloomberg B-PIPE process. This example uses the Bloomberg B-PIPE C++ interface and assumes the following:

  • The authentication is Windows authentication when you set authtype to 'OS_LOGON'.

  • The application name is blank because you are not connecting to Bloomberg B-PIPE using an application.

  • The IP address for the machine running the Bloomberg B-PIPE process is '111.11.11.112'.

  • The port number of the machine running the Bloomberg B-PIPE process is 8194.

c is a bloombergBPIPE object.

authtype = 'OS_LOGON';
appname = '';
ipaddress = {'111.11.11.112'};
port = 8194;

c = bloombergBPIPE(authtype,appname,ipaddress,port);

Get the monthly closing price from August 1, 2010, through August 1, 2011, for the IBM security in US currency. The period values 'monthly', 'actual', and 'all_calendar_days' specify returning actual monthly data for all calendar days. The period value 'nil_value' specifies filling missing data values with a NaN.

[d,sec] = history(c,'IBM US Equity','LAST_PRICE',...
                  '8/01/2010','8/01/2011',{'monthly','actual',...
                  'all_calendar_days','nil_value'},'USD')
d =

     734351.00        128.40
     734382.00        125.77
     734412.00        135.64
     734443.00        143.32
     734473.00        144.41
     734504.00        146.76
     734535.00        163.56
     734563.00        159.97
     734594.00        164.27
     734624.00        170.58
     734655.00        166.56
     734685.00        174.54
     734716.00        180.75


sec = 

    'IBM US Equity'

d contains the numeric representation for the date in the first column and the closing price in the second column. sec contains the name of the IBM security.

Close the Bloomberg connection.

close(c)

First, create a Bloomberg Desktop connection. Then, retrieve the daily closing prices for a security within a date range. Specify prices using the US currency. Use name-value pair arguments to adjust the prices.

Create a Bloomberg B-PIPE connection using the IP address of the machine running the Bloomberg B-PIPE process. This example uses the Bloomberg B-PIPE C++ interface and assumes the following:

  • The authentication is Windows authentication when you set authtype to 'OS_LOGON'.

  • The application name is blank because you are not connecting to Bloomberg B-PIPE using an application.

  • The IP address for the machine running the Bloomberg B-PIPE process is '111.11.11.112'.

  • The port number of the machine running the Bloomberg B-PIPE process is 8194.

c is a bloombergBPIPE object.

authtype = 'OS_LOGON';
appname = '';
ipaddress = {'111.11.11.112'};
port = 8194;

c = bloombergBPIPE(authtype,appname,ipaddress,port);

Get the daily closing price from August 1, 2010, through August 10, 2010, for the IBM security in U.S. currency 'USD'. The prices are adjusted for normal cash and splits.

[d,sec] = history(c,'IBM US Equity','LAST_PRICE',...
                  '8/01/2010','8/10/2010','daily','USD',...
                  'adjustmentNormal',true,...
                  'adjustmentSplit',true)
d =

     734352.00        123.55
     734353.00        123.18
     734354.00        124.03
     734355.00        124.56
     734356.00        123.58
     734359.00        125.34
     734360.00        125.19


sec = 

    'IBM US Equity'

d contains the numeric representation for the date in the first column and the closing price in the second column. sec contains the name of the IBM security.

Close the Bloomberg connection.

close(c)

First, create a Bloomberg Desktop connection. Then, retrieve the daily closing prices for a security within a date range. Specify the security using the CUSIP number and a pricing source.

Create a Bloomberg B-PIPE connection using the IP address of the machine running the Bloomberg B-PIPE process. This example uses the Bloomberg B-PIPE C++ interface and assumes the following:

  • The authentication is Windows authentication when you set authtype to 'OS_LOGON'.

  • The application name is blank because you are not connecting to Bloomberg B-PIPE using an application.

  • The IP address for the machine running the Bloomberg B-PIPE process is '111.11.11.112'.

  • The port number of the machine running the Bloomberg B-PIPE process is 8194.

c is a bloombergBPIPE object.

authtype = 'OS_LOGON';
appname = '';
ipaddress = {'111.11.11.112'};
port = 8194;

c = bloombergBPIPE(authtype,appname,ipaddress,port);

Get the daily closing price from January 1, 2012, through January 1, 2013, for the security specified with a CUSIP number /cusip/459200101 and with pricing source BGN.

d contains the numeric representation for the date in the first column and the closing price in the second column.

d = history(c,'/cusip/459200101@BGN','LAST_PRICE',...
            '01/01/2012','01/01/2013')
d =

     734871.00        180.69
     734872.00        179.96
     734873.00        179.10
     ...

Close the Bloomberg connection.

close(c)

First, create a Bloomberg Desktop connection. Then, retrieve the closing prices for a security within a date range. Specify the dates for the range using an international date format.

Create a Bloomberg B-PIPE connection using the IP address of the machine running the Bloomberg B-PIPE process. This example uses the Bloomberg B-PIPE C++ interface and assumes the following:

  • The authentication is Windows authentication when you set authtype to 'OS_LOGON'.

  • The application name is blank because you are not connecting to Bloomberg B-PIPE using an application.

  • The IP address for the machine running the Bloomberg B-PIPE process is '111.11.11.112'.

  • The port number of the machine running the Bloomberg B-PIPE process is 8194.

c is a bloombergBPIPE object.

authtype = 'OS_LOGON';
appname = '';
ipaddress = {'111.11.11.112'};
port = 8194;

c = bloombergBPIPE(authtype,appname,ipaddress,port);

Return the closing price for the given dates in international format for the security 'MSFT@BGN US Equity'.

stDt = datenum('01/06/11','dd/mm/yyyy'); 
endDt = datenum('01/06/12','dd/mm/yyyy'); 
[d,sec] = history(c,'MSFT@BGN US Equity','LAST_PRICE',...
                  stDt,endDt,{'previous_value','all_calendar_days'})
d =

     734655.00         22.92
     734656.00         22.72
     734657.00         22.42
     ...

sec = 

    'MSFT@BGN US Equity'

d contains the numeric representation for the date in the first column and the closing price in the second column. sec contains the name of the IBM security.

Close the Bloomberg connection.

close(c)

First, create a Bloomberg Desktop connection. Then, retrieve the median earnings per share for a security within a date range. Specify an override field and value.

Create a Bloomberg B-PIPE connection using the IP address of the machine running the Bloomberg B-PIPE process. This example uses the Bloomberg B-PIPE C++ interface and assumes the following:

  • The authentication is Windows authentication when you set authtype to 'OS_LOGON'.

  • The application name is blank because you are not connecting to Bloomberg B-PIPE using an application.

  • The IP address for the machine running the Bloomberg B-PIPE process is '111.11.11.112'.

  • The port number of the machine running the Bloomberg B-PIPE process is 8194.

c is a bloombergBPIPE object.

authtype = 'OS_LOGON';
appname = '';
ipaddress = {'111.11.11.112'};
port = 8194;

c = bloombergBPIPE(authtype,appname,ipaddress,port);

Retrieve the median estimated earnings per share for AkzoNobel® from October 1, 2010, through October 30, 2010. When specifying Bloomberg override fields, use the character vector 'overrideFields'. The overrideFields argument must be an n-by-2 cell array, where the first column is the override field and the second column is the override value.

d = history(c,'AKZA NA Equity', ...
            'BEST_EPS_MEDIAN',datenum('01.10.2010', ...
            'dd.mm.yyyy'),datenum('30.10.2010','dd.mm.yyyy'), ...
            {'daily','calendar'},[],'overrideFields', ...
            {'BEST_FPERIOD_OVERRIDE','BF'})
d =

     734412.00          3.75
     734415.00          3.75
     734416.00          3.75
     ...

d returns the numeric representation for the date in the first column and the median estimated earnings per share in the second column.

Close the Bloomberg connection.

close(c)

Create a Bloomberg connection, and then retrieve closing prices for a historical date range. The history function returns data for dates as a datetime array.

Create a Bloomberg B-PIPE connection using the IP address of the machine running the Bloomberg B-PIPE process. This example uses the Bloomberg B-PIPE C++ interface and assumes the following:

  • The authentication is Windows authentication when you set authtype to 'OS_LOGON'.

  • The application name is blank because you are not connecting to Bloomberg B-PIPE using an application.

  • The IP address for the machine running the Bloomberg B-PIPE process is '111.11.11.112'.

  • The port number of the machine running the Bloomberg B-PIPE process is 8194.

c is a bloombergBPIPE object.

authtype = 'OS_LOGON';
appname = '';
ipaddress = {'111.11.11.112'};
port = 8194;

c = bloombergBPIPE(authtype,appname,ipaddress,port);

Return data as a table by setting the DataReturnFormat property of the connection object. If you do not set this property, the history function returns data as a numeric array.

Return dates as a datetime array by setting the DatetimeType property of the connection object. In this case, the table contains dates in variables that are datetime arrays.

c.DataReturnFormat = 'table';
c.DatetimeType = 'datetime';

Adjust the display format of the returned data for currency.

format bank

Retrieve historical closing prices for IBM from August 1, 2010, through August 10, 2010. d is a table that contains dates as a datetime array.

[d,sec] = history(c,'IBM US Equity','LAST_PRICE', ...
    '8/01/2010','8/10/2010')
d =

  7×2 table

       DATE        LAST_PRICE
    ___________    __________

    02-Aug-2010      130.76  
    03-Aug-2010      130.37  
    04-Aug-2010      131.27  
    05-Aug-2010      131.83  
    06-Aug-2010      130.14  
    09-Aug-2010      132.00  
    10-Aug-2010      131.84  


sec =

  1×1 cell array

    {'IBM US Equity'}

Access dates in the returned data.

d.DATE
ans = 

  7×1 datetime array

   02-Aug-2010
   03-Aug-2010
   04-Aug-2010
   05-Aug-2010
   06-Aug-2010
   09-Aug-2010
   10-Aug-2010

Close the Bloomberg connection.

close(c)

Create a Bloomberg connection, and then retrieve closing prices for a historical date range. The history function returns data as a timetable.

Create a Bloomberg B-PIPE connection using the IP address of the machine running the Bloomberg B-PIPE process. This example uses the Bloomberg B-PIPE C++ interface and assumes the following:

  • The authentication is Windows authentication when you set authtype to 'OS_LOGON'.

  • The application name is blank because you are not connecting to Bloomberg B-PIPE using an application.

  • The IP address for the machine running the Bloomberg B-PIPE process is '111.11.11.112'.

  • The port number of the machine running the Bloomberg B-PIPE process is 8194.

c is a bloombergBPIPE object.

authtype = 'OS_LOGON';
appname = '';
ipaddress = {'111.11.11.112'};
port = 8194;

c = bloombergBPIPE(authtype,appname,ipaddress,port);

Return data as a timetable by setting the DataReturnFormat property of the connection object. If you do not set this property, the history function returns data as a numeric array.

c.DataReturnFormat = 'timetable';

Adjust the display format of the returned data for currency.

format bank

Retrieve historical closing prices for IBM from August 1, 2010, through August 10, 2010. d is a timetable that contains dates in the first column.

[d,sec] = history(c,'IBM US Equity','LAST_PRICE', ...
    '8/01/2010','8/10/2010')
d =

  7×1 timetable

       DATE        LAST_PRICE
    ___________    __________

    02-Aug-2010      130.76  
    03-Aug-2010      130.37  
    04-Aug-2010      131.27  
    05-Aug-2010      131.83  
    06-Aug-2010      130.14  
    09-Aug-2010      132.00  
    10-Aug-2010      131.84  


sec =

  1×1 cell array

    {'IBM US Equity'}

Access dates in the returned data.

d.DATE
ans = 

  7×1 datetime array

   02-Aug-2010
   03-Aug-2010
   04-Aug-2010
   05-Aug-2010
   06-Aug-2010
   09-Aug-2010
   10-Aug-2010

Close the Bloomberg connection.

close(c)

Input Arguments

collapse all

Bloomberg B-PIPE connection, specified as a bloombergBPIPE object.

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

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

Periodicity, specified as one of these values to denote the data to return. For specifying multiple values, use a cell array. For example, when period is set to {'daily','all_calendar_days'}, history returns daily data for all calendar days, and reports missing data as NaNs. When period is set to 'active_days_only', history returns data using the default periodicity for active trading days only. The default periodicity depends on the security. If a security is reported on a monthly basis, the default periodicity is monthly. These tables show the values for period.

To specify the periodicity of the return data, see this table.

ValueDescription
'daily'

Return data for each day.

'weekly'

Return data for each week.

'monthly'

Return data for each month.

'quarterly'

Return data for each quarter.

'semi_annually'

Return data semiannually.

'yearly'

Return data for each year.

The anchor date is the date to which all other reported dates are related. To specify the anchor date, see this table.

ValueDescription
'actual'

Anchor date specification for an actual date. For this function, for periodicities other than daily, todate is the anchor date.

If the period is weekly and the todate is a Thursday, every data point is a Thursday, or the nearest prior business day to Thursday. If the period is monthly and the todate is the 20th of a month, every data point is the 20th of each month in the date range.

'calendar'

Anchor date specification for a calendar year.

'fiscal'

Anchor date specification for a fiscal year.

'none'

Do not specify the anchor date.

To specify returning data for particular days, see this table.

ValueDescription
'non_trading_weekdays'Return data for all weekdays.
'all_calendar_days'Return data for all calendar days.
'active_days_only'Return data for only active trading days.

To specify how to fill missing values, see this table.

ValueDescription
'previous_value'Fill missing values with previous values for dates without trading activity for the security. If no previous value exists in the month before the fromdate, this function retains the missing values.
'nil_value'Fill missing values with a NaN for dates without trading activity for the security.

Data Types: char | cell

Currency, specified as a character vector or string scalar to denote the ISO® code for the currency of the returned data. For example, to specify output money values in U.S. currency, use USD for this argument.

Data Types: char | string

Beginning date for the historical data, specified as a double scalar, character vector, string scalar, or datetime array. You can specify dates in any of the formats supported by datestr and datenum that show a year, month, and day.

Data Types: datetime | double | char | string

End date for the historical data, specified as a double scalar, character vector, string scalar, or datetime array. You can specify dates in any of the formats supported by datestr and datenum that show a year, month, and day.

Data Types: datetime | double | char | string

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: 'adjustmentNormal',true

Override fields, specified as the comma-separated pair consisting of 'overrideFields' and an n-by-2 cell array. The first column of the cell array is the override field and the second column is the override value.

Example: 'overrideFields',{'IVOL_DELTA_LEVEL','DELTA_LVL_10';'IVOL_DELTA_PUT_OR_CALL','IVOL_PUT';'IVOL_MATURITY','MATURITY_1STM'}

Data Types: cell

Historical normal pricing adjustment, specified as the comma-separated pair consisting of 'adjustmentNormal' and a Boolean to reflect:

  • Regular Cash

  • Interim

  • 1st Interim

  • 2nd Interim

  • 3rd Interim

  • 4th Interim

  • 5th Interim

  • Income

  • Estimated

  • Partnership Distribution

  • Final

  • Interest on Capital

  • Distribution

  • Prorated

For details about these additional name-value pairs, see the Bloomberg API Developer’s Guide using the WAPI <GO> option from the Bloomberg terminal.

Data Types: logical

Historical abnormal pricing adjustment, specified as the comma-separated pair consisting of 'adjustmentAbnormal' and a Boolean to reflect:

  • Special Cash

  • Liquidation

  • Capital Gains

  • Long-Term Capital Gains

  • Short-Term Capital Gains

  • Memorial

  • Return of Capital

  • Rights Redemption

  • Miscellaneous

  • Return Premium

  • Preferred Rights Redemption

  • Proceeds/Rights

  • Proceeds/Shares

  • Proceeds/Warrants

For details about these additional name-value pairs, see the Bloomberg API Developer’s Guide using the WAPI <GO> option from the Bloomberg terminal.

Data Types: logical

Historical split pricing or volume adjustment, specified as the comma-separated pair consisting of 'adjustmentSplit' and a Boolean to reflect:

  • Spin-Offs

  • Stock Splits/Consolidations

  • Stock Dividend/Bonus

  • Rights Offerings/Entitlement

For details about these additional name-value pairs, see the Bloomberg API Developer’s Guide using the WAPI <GO> option from the Bloomberg terminal.

Data Types: logical

Historical pricing adjustment, specified as the comma-separated pair consisting of 'adjustmentFollowDPDF' and a Boolean. Setting this name-value pair follows the DPDF <GO> option from the Bloomberg terminal. For details about these additional name-value pairs, see the Bloomberg API Developer’s Guide using the WAPI <GO> option from the Bloomberg terminal.

Data Types: logical

Output Arguments

collapse all

Bloomberg historical data, returned as a numeric array, table, or timetable. The data type of the historical data depends on the DataReturnFormat and DatetimeType properties of the connection object. The first column (or field) in the historical data contains the date. The remaining columns contain the requested data fields.

For details about the data, see the Bloomberg API Developer’s Guide using the WAPI <GO> option from the Bloomberg terminal.

Security list, returned as a cell array of character vectors for the corresponding securities in s. The contents of sec are identical in value and order to s. You can return securities with any of the following identifiers:

  • buid

  • cats

  • cins

  • common

  • cusip

  • isin

  • sedol1

  • sedol2

  • sicovam

  • svm

  • ticker (default)

  • wpk

Tips

  • You can check data and field availability by using the Bloomberg Excel® Add-In.

Version History

Introduced in R2021a