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.

fetch

Request data from Haver Analytics database

Syntax

d = fetch(c,variable)
d = fetch(c,variable,startdate,enddate)
d = fetch(c,variable,startdate,enddate,period)

Description

example

d = fetch(c,variable) returns historical data for the Haver Analytics® variable s, using the connection object c.

example

d = fetch(c,variable,startdate,enddate) returns historical data between the dates startdate and enddate.

example

d = fetch(c,variable,startdate,enddate,period) returns historical data in time periods specified by period.

Examples

collapse all

Connect to the Haver Analytics database.

c = haver('c:\work\haver\haverd.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 database connection.

close(c)

Connect to the Haver Analytics database.

c = haver('c:\work\haver\haverd.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 database connection.

close(c)

Connect to the Haver Analytics database.

c = haver('c:\work\haver\haverd.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 database connection.

close(c)

Input Arguments

collapse all

Haver Analytics connection, specified as a connection object created using haver.

Haver Analytics variable, specified as a character vector or string scalar to denote which historical data to retrieve.

Example: 'FFED'

Data Types: char | string

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

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, 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

collapse all

Historical data, returned as a matrix with the numeric representation of the date in the first column and the value in the second column.

Introduced in R2007a

Was this topic helpful?