fetch
Request data from Haver Analytics database
Syntax
Description
Examples
Retrieve Variable Data
Connect to the Haver Analytics database.
c = haver('c:\work\haver\usecon.dat');
Retrieve all historical data for the Haver Analytics variable 'FFED'
. The descriptor for
this variable is Federal Funds [Effective] Rate (% p.a.).
variable = 'FFED'; % return data for FFED d = fetch(c,variable);
Display the first three rows of data.
d(1:3,:)
ans = 715511.00 2.38 715512.00 2.50 715515.00 2.50
d
contains the numeric representation of the date
in the first column and the closing value in the second column.
Close the Haver Analytics connection.
close(c)
Retrieve Variable Data for Specified Date Range
Connect to the Haver Analytics database.
c = haver('c:\work\haver\usecon.dat');
Retrieve historical data from January 1, 2005, through December 31,
2005, for 'FFED'
.
variable = 'FFED'; % return data for FFED startdate = '01/01/2005'; % start of date range enddate = '12/31/2005'; % end of date range d = fetch(c,variable,startdate,enddate);
Display the first three rows of data.
d(1:3,:)
ans = 732315.00 2.25 732316.00 2.25 732317.00 2.25
d
contains the numeric representation of the date
in the first column and the closing value in the second column.
Close the Haver Analytics connection.
close(c)
Retrieve Quarterly Data for Specified Date Range
Connect to the Haver Analytics database.
c = haver('c:\work\haver\usecon.dat');
Retrieve the information of the Haver Analytics variable 'FFED'
. The descriptor for
this variable is Federal Funds [Effective] Rate (% p.a.).
variable = 'FFED';
x = info(c,variable);
info
returns the structure x
containing fields describing the Haver Analytics variable.
Retrieve quarterly data. When you specify a date that is outside the
date range in the variable, you might experience unexpected results.
To prevent this, use the EndDate
field for the end
of the date range.
startdate = '06/01/2000'; % start of date range enddate = x.EndDate; % end of date range period = 'q'; % quarterly data d = fetch(c,variable,startdate,enddate,period)
Display the first three rows of data.
d(1:3,:)
ans = 730759.00 6.52 730851.00 6.50 730941.00 5.61
d
contains the numeric representation of the date
in the first column and the closing value in the second column.
Close the Haver Analytics connection.
close(c)
Retrieve Variable Data as Table
Connect to the Haver Analytics database.
c = haver('c:\work\haver\usecon.dat');
Adjust the display format for currency.
format bank
Set the data return format to table using the
DataReturnFormat
property of the
haver
object.
c.DataReturnFormat = 'table';
Retrieve historical data from January 1, 2005, through December 31,
2005, for 'ABQ'
and display the results.
ABQ
provides bankruptcy filings in the
US.
variable = 'ABQ'; % return data for ABQ startdate = '01/01/2005'; % start of date range enddate = '12/31/2005'; % end of date range d = fetch(c,variable,startdate,enddate)
ans = 4×2 table Time TotalBankruptcyFilings_U_S__Units_ _________ __________________________________ 732402.00 401149.00 732493.00 467333.00 732585.00 542002.00 732677.00 667431.00
d
is a table with the date in the first variable
and the bankruptcy amount in the second variable. The date is an array
of MATLAB® date numbers.
Close the Haver Analytics connection.
close(c)
Retrieve Variable Data as Table with Datetime
Connect to the Haver Analytics database.
c = haver('c:\work\haver\usecon.dat');
Adjust the display format for currency.
format bank
Set the data return format to table using the
DataReturnFormat
property of the
haver
object. Also, set the date and time return
format to a datetime
array using the
DatetimeType
property.
c.DataReturnFormat = 'table'; c.DatetimeType = 'datetime';
Retrieve historical data from January 1, 2005, through December 31,
2005, for 'ABQ'
and display the results.
ABQ
provides bankruptcy filings in the
US.
variable = 'ABQ'; % return data for ABQ startdate = '01/01/2005'; % start of date range enddate = '12/31/2005'; % end of date range d = fetch(c,variable,startdate,enddate)
ans = 4×2 table Time TotalBankruptcyFilings_U_S__Units_ ____________________ __________________________________ 31-Mar-2005 00:00:00 401149.00 30-Jun-2005 00:00:00 467333.00 30-Sep-2005 00:00:00 542002.00 31-Dec-2005 00:00:00 667431.00
d
is a table with the date and time in the first
variable and the bankruptcy amount in the second variable. The first
variable is a datetime
array.
Close the Haver Analytics connection.
close(c)
Input Arguments
c
— Haver Analytics connection
connection object
Haver Analytics connection, specified as a connection object created
using haver
.
variable
— Haver Analytics variable
character vector | string scalar | cell array of character vectors | string array
Haver Analytics variable, specified as a character vector, string scalar, cell array of character vectors, or string array to denote which historical data to retrieve.
Example: 'FFED'
Data Types: char
| string
| cell
startdate
— Start date
character vector | string scalar | MATLAB date number
Start date, specified as a character vector, string scalar, or MATLAB date number that denotes the beginning of the date range to retrieve data.
Data Types: double
| char
| string
enddate
— End date
character vector | string scalar | MATLAB date number
End date, specified as a character vector, string scalar, or MATLAB date number that denotes the end of the date range to retrieve data.
Data Types: double
| char
| string
period
— Period
'd'
| 'w'
| 'm'
| 'q'
| 'a'
Period, specified as one of these values that denotes the time period for the historical data:
'd'
for daily values'w'
for weekly values'm'
for monthly values'q'
for quarterly values'a'
for annual values
Output Arguments
d
— Historical data
matrix
Historical data, returned as a matrix with the numeric representation of the date in the first column and the value in the second column.
Version History
Introduced in R2007a
See Also
MATLAB コマンド
次の MATLAB コマンドに対応するリンクがクリックされました。
コマンドを MATLAB コマンド ウィンドウに入力して実行してください。Web ブラウザーは MATLAB コマンドをサポートしていません。
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)