FRED
FRED Dependencies
FRED relies on the optional dependency fredapi. If you did not opt-in for optional dependencies, you can run:
to get the required packages.
API Key Required
An API key from the "St. Louis FED" is required for the FRED class to operate. If you don't have an API key, you can generate one for free by making an account on FRED.
FRED allows easy retrieval of time series stored in the FRED database. The class can identify the given key_name if placed in the .env file anywhere in the discoverable file tree of the project. Alternatively, you can specify an env file that contains key_name in it.
.env File Discovery
find_dotenv is used for discovery. It will walk up the directory tree towards the project root until it encounters a file named ".env".
Methods:
FRED.get_series(
series_id: str,
date_range: tuple[str, str] | pd.DatetimeIndex | Literal['max', 'ytd'] | None
) -> pd.Series
| Argument | Description |
|---|---|
| series_id | The FRED ID of the requested series. |
| date_range | Date range in either a YYYY-MM-DD format string pair, a DatetimeIndex, or a string literal 'max', 'ytd'. None defaults to 'max'. |
Returns:
| Type: | Description |
|---|---|
pd.Series |
The requested time series in a formatted pandas object. |
FRED.get_frame(
series_ids: list[str],
date_range: tuple[str, str] | pd.DatetimeIndex | Literal['max', 'ytd'] | None
) -> pd.DataFrame
Returns multiple requested series in a DataFrame.
| Argument | Description |
|---|---|
| series_ids | The FRED IDs of the requested series. |
| date_range | Date range in either a YYYY-MM-DD format string pair, a DatetimeIndex, or a string literal 'max', 'ytd'. None defaults to 'max'. |
Returns:
| Type: | Description |
|---|---|
pd.DataFrame |
The requested time series in a formatted pandas object. |