history
Historical data for Bloomberg connection V3
Syntax
Description
returns the historical data for the security list d
= history(c
,s
,f
,fromdate
,todate
)s
and the
connection object c
for the fields f
for the
dates fromdate
through todate
. 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
.
Examples
Daily Closing Prices Within Date Range
First, create a Bloomberg® Desktop connection. Then, retrieve the daily closing price for a security within a date range.
Create the Bloomberg connection.
c = blp;
Alternatively, you can connect to the Bloomberg Server using blpsrv
or Bloomberg
B-PIPE® using bpipe
.
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)
Monthly Closing Prices Within Date Range
First, create a Bloomberg Desktop connection. Then, retrieve the monthly closing prices for a security within a date range.
Create the Bloomberg connection.
c = blp;
Alternatively, you can connect to the Bloomberg Server using blpsrv
or Bloomberg
B-PIPE using bpipe
.
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)
Monthly Closing Prices Within Date Range Using US Currency
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 the Bloomberg connection.
c = blp;
Alternatively, you can connect to the Bloomberg Server using blpsrv
or Bloomberg
B-PIPE using bpipe
.
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)
Monthly Closing Prices Within Date Range Using Currency with Specified Period
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 the Bloomberg connection.
c = blp;
Alternatively, you can connect to the Bloomberg Server using blpsrv
or Bloomberg
B-PIPE using bpipe
.
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)
Daily Closing Prices Within Date Range Using Currency with Name-Value Pairs
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 the Bloomberg connection.
c = blp;
Alternatively, you can connect to the Bloomberg Server using blpsrv
or Bloomberg
B-PIPE using bpipe
.
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)
Daily Closing Prices Using CUSIP Number and Pricing Source
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 the Bloomberg connection.
c = blp;
Alternatively, you can connect to the Bloomberg Server using blpsrv
or Bloomberg
B-PIPE using bpipe
.
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)
Closing Prices Within Date Range Using International Date Format
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 the Bloomberg connection.
c = blp;
Alternatively, you can connect to the Bloomberg Server using blpsrv
or Bloomberg
B-PIPE using bpipe
.
Return the closing price for the given dates in international format for
the security 'MSFT@BGN US Equity'
.
stDt = datetime('01/06/11','InputFormat','dd/MM/yy'); endDt = datetime('01/06/12','InputFormat','dd/MM/yy'); [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)
Median Estimated Earnings Per Share Using Override Fields
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 the Bloomberg connection.
c = blp;
Alternatively, you can connect to the Bloomberg Server using blpsrv
or Bloomberg
B-PIPE using bpipe
.
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', ... datetime('01.10.2010','InputFormat','dd.MM.yyyy'), ... datetime('30.10.2010','InputFormat','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)
Historical Data as Table with Dates
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 the Bloomberg connection.
c = blp;
Alternatively, you can connect to the Bloomberg Server using blpsrv
or Bloomberg B-PIPE® using bpipe
.
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)
Historical Data as Timetable
Create a Bloomberg® connection, and then retrieve closing prices for a historical date range. The history
function returns data as a timetable
.
Create the Bloomberg connection.
c = blp;
Alternatively, you can connect to the Bloomberg Server using blpsrv
or Bloomberg B-PIPE® using bpipe
.
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
s
— Security list
character vector | string scalar | cell array of character vectors | string array
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
f
— Bloomberg data fields
character vector | string scalar | cell array of character vectors | string array
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
period
— Periodicity
'daily'
| 'weekly'
| 'monthly'
| 'quarterly'
| ...
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 NaN
s. 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.
Value | Description |
---|---|
'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.
Value | Description |
---|---|
'actual' |
Anchor date specification for an actual date. For
this function, for periodicities other than daily,
If the period is weekly and the
|
'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.
Value | Description |
---|---|
'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.
Value | Description |
---|---|
'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
— Currency
character vector | string scalar
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
fromdate
— Beginning date
double scalar | character vector | string scalar | datetime
Beginning date for the historical data, specified as a double scalar,
character vector, string scalar, or datetime
array.
Data Types: datetime
| double
| char
| string
todate
— End date
double scalar | character vector | string scalar | datetime
End date for the historical data, specified as a double scalar, character
vector, string scalar, or datetime
array.
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
overrideFields
— Override fields
cell array
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
adjustmentNormal
— Historical normal pricing adjustment
true | false
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
adjustmentAbnormal
— Historical abnormal pricing adjustment
true | false
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
adjustmentSplit
— Historical split pricing or volume adjustment
true | false
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
adjustmentFollowDPDF
— Historical pricing adjustment
true (default) | false
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
d
— Bloomberg historical data
numeric array (default) | table | timetable
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.
sec
— Security list
cell array of character vectors
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
For better performance, add the Bloomberg file
blpapi3.jar
to the MATLAB static Java® class path by modifying the file$MATLAB/toolbox/local/javaclasspath.txt
. For details about the static Java class path, see Static Path of Java Class Path.You can check data and field availability by using the Bloomberg Excel® Add-In.
Version History
Introduced in R2010a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)