Processing Financial Data with FRED API: Difference between revisions
Jump to navigation
Jump to search
Line 28: | Line 28: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
The series is already time-indexed. | The series is already time-indexed: | ||
<font size=-2> | |||
2013-10-07 1676.12 | |||
2013-10-08 1655.45 | |||
2013-10-09 1656.40 | |||
2013-10-10 1692.56 | |||
2013-10-11 1703.20 | |||
... | |||
2023-10-02 4288.39 | |||
2023-10-03 4229.45 | |||
2023-10-04 4263.75 | |||
2023-10-05 4258.19 | |||
2023-10-06 4308.50 | |||
Length: 2610, dtype: float64 | |||
</font> |
Revision as of 19:40, 8 October 2023
Internal
Overview
This article describes the sequence of steps required to process financial data obtained from FRED API.
Procedure
Import the package and establish a connection to the FRED backend, providing the API Key obtained as described here.
from fredapi import Fred
fred = Fred(api_key='...')
Search for a dataset using full text search. The result is a DataFrame.
df = fred.search("S&P", limit=1000, order_by=None, sort_order=None, filter=None)
The exploration yields a series with the ID "SP500".
Retrieve the Series:
s = fred.get_series(series_id="SP500")
The series is already time-indexed:
2013-10-07 1676.12 2013-10-08 1655.45 2013-10-09 1656.40 2013-10-10 1692.56 2013-10-11 1703.20 ... 2023-10-02 4288.39 2023-10-03 4229.45 2023-10-04 4263.75 2023-10-05 4258.19 2023-10-06 4308.50 Length: 2610, dtype: float64