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 FRED data servers

Syntax

d = fetch(c,series)
d = fetch(c,series,date)
d = fetch(c,series,startdate,enddate)

Description

example

d = fetch(c,series) returns FRED® data using the FRED connection c and the specified FRED series.

example

d = fetch(c,series,date) returns FRED data for a specific date.

example

d = fetch(c,series,startdate,enddate) returns FRED data for the date range from startdate through enddate.

Examples

collapse all

Connect to the FRED® data server using the URL 'https://fred.stlouisfed.org/'.

url = 'https://fred.stlouisfed.org/';
c = fred(url);

Fetch all available daily foreign exchange rates between the US dollar and the Euro using the series 'DEXUSEU'.

series = 'DEXUSEU';
d = fetch(c,series)
d = 

  struct with fields:

                 Title: ' U.S. / Euro Foreign Exchange Rate'
              SeriesID: ' DEXUSEU'
                Source: ' Board of Governors of the Federal Reserve System (US)'
               Release: ' H.10 Foreign Exchange Rates'
    SeasonalAdjustment: ' Not Seasonally Adjusted'
             Frequency: ' Daily'
                 Units: ' U.S. Dollars to One Euro'
             DateRange: ' 1999-01-04 to 2017-02-03'
           LastUpdated: ' 2017-02-06 3:52 PM CST'
                 Notes: ' Noon buying rates in New York City for cable transfers payable in foreign currencies.'
                  Data: [4720×2 double]

d.Data is an N-by-2 double array that contains dates in the first column and the series values in the second column.

Close the FRED® connection.

close(c)

Connect to the FRED® data server using the URL 'https://fred.stlouisfed.org/'.

url = 'https://fred.stlouisfed.org/';
c = fred(url);

Adjust the display data format for currency.

format bank

Fetch data for a day three months ago using the series 'DTB6'.

series = 'DTB6';
date = floor(now)-90;
d = fetch(c,series,date)
d = 

  struct with fields:

                 Title: ' 6-Month Treasury Bill: Secondary Market Rate'
              SeriesID: ' DTB6'
                Source: ' Board of Governors of the Federal Reserve System (US)'
               Release: ' H.15 Selected Interest Rates'
    SeasonalAdjustment: ' Not Seasonally Adjusted'
             Frequency: ' Daily'
                 Units: ' Percent'
             DateRange: ' 1958-12-09 to 2017-02-06'
           LastUpdated: ' 2017-02-07 3:51 PM CST'
                 Notes: ' Discount Basis'
                  Data: [736644.00 0.58]

d.Data is an N-by-2 double array that contains the date in the first column and the series value in the second column.

Close the FRED® connection.

close(c)

Connect to the FRED® data server using the URL 'https://fred.stlouisfed.org/'.

url = 'https://fred.stlouisfed.org/';
c = fred(url);

Adjust the display data format for currency.

format bank

Retrieve historical data for the US / Euro Foreign Exchange Rate series.

series = 'DEXUSEU';

Fetch five months of data from January 1, 2007 through June 1, 2007.

startdate = '01/01/2007';
enddate = '06/01/2007';
d = fetch(c,series,startdate,enddate)
d = 

  struct with fields:

                 Title: ' U.S. / Euro Foreign Exchange Rate'
              SeriesID: ' DEXUSEU'
                Source: ' Board of Governors of the Federal Reserve System (US)'
               Release: ' H.10 Foreign Exchange Rates'
    SeasonalAdjustment: ' Not Seasonally Adjusted'
             Frequency: ' Daily'
                 Units: ' U.S. Dollars to One Euro'
             DateRange: ' 1999-01-04 to 2017-02-03'
           LastUpdated: ' 2017-02-06 3:52 PM CST'
                 Notes: ' Noon buying rates in New York City for cable transfers payable in foreign currencies.'
                  Data: [110×2 double]

d.Data is an N-by-2 double array that contains dates in the first column and the series values in the second column.

Close the FRED® connection.

close(c)

Input Arguments

collapse all

FRED connection, specified as a connection object created using fred.

FRED series, specified as a character vector or string scalar.

Example: 'DEXUSEU'

Data Types: char | string

Date, specified as a datetime value, matrix, character vector, or string scalar. For details about the data types, see datenum.

Data Types: double | char | cell | datetime | string

Start date in a date range, specified as a datetime value, matrix, character vector, or string scalar. For details about the data types, see datenum.

Data Types: double | char | cell | datetime | string

End date in a date range, specified as a datetime value, matrix, character vector, or string scalar. For details about the data types, see datenum.

Data Types: double | char | cell | datetime | string

Output Arguments

collapse all

FRED data, returned as a structure. For details about FRED data, see https://research.stlouisfed.org/fred2/.

Introduced in R2006b

Was this topic helpful?