Economics Wrapper for data across multiple domains and sources (FRED, BEA, BLS, IPUMS, etc.). The structures allow for smooth workflows for data ingest, transformations, graphing, and modeling.
This module is used independently of any particular API-wrapper. However, some wrappers are suggested and used in the examples. An API-wrapper Adapter interface is available for improved integration with this module's primary classes. Where no API-wrapper functionality exists, such as directly downloading files or site scraping, this module makes direct connections to a site by implementing the Extractor interface.
Create a file (SECRETS.yaml) with all appropriate keys and values.
pip install macroecon_wrappySelect a source and associated wrapper. For this example, we will use the fredapi wrapper with the FRED data source. The Adapter is provided for this wrapper, but you can create your own if you use a different API-wrapper.
Set the authentication key for the wrapper.
Add external libraries using the --dev argument, such as:
uv add --dev waybackpack<TODO: add from notebooks/test.ipynb>Using the FredApi Adapter enables seemless integration with the rest of the module, in particular, incorporating data series into Measures.
<TODO: add from notebooks/test.ipynb>Work directly with the Measure for various tasks and transformations.
uv run pytest --collect-onlyIts often best to work with the notebook while quickly developing.
uv pip install -e .Then simply import into the notebook
import macroecon_wrappy as meBut ensure to remove it when done:
uv pip uninstall macroecon_wrappyThese API-wrappers are supported by this module with Adapters:
- fredapi
- treasury_fiscaldata: us-federal-treasury-python-api
- requires install with
pip install ./test_modules/us-federal-treasury-python-api/.
- requires install with
- internet_archive
- yfinance
- Relation
- multiple Measures, Epochs, Events related using a mathematical expression
Measure line on a graph- (ie consumer inflation) contains multiple Metrics (cpi, core cpi, pce, bpp, etc.)
- list of Metrics
Metric - continuous timeseries data- pd.Series with metadata
- Epoch polygon on a graph
- (ie recessions) contain multiple Epochs (expansion, contraction, etc.)
- pd.DataFrame of Epochs with metadata
- Span - window of time
- single row of pd.DataFrame with metadata
- Event dot on a graph
- (ie fall of enron) contains multiple Points (news articles, blog posts, anecdotes, etc.)
- pd.DataFrame of Points with metadata
- Point in time (ie news article)
- single row of pd.DataFrame with metadata
- Geom abstract structure with metadata
Adapter - interacts with api wrapper to get data Extractor - interacts with site to get files and extract data
Span of duration_days == 0 is Event- Adapters and Extractors should enforce output of
?list of dicts,with opinionated methods for how to use with data structures (Span, Metric, etc.)return raw structure (dict, pd.DataFrame)return macroecon structure (Measure, Epoch, Event, Geom)enable caching of data using module, top-level config, and work with api-wrappers' own caching
- what is load.py doing? dependencies: RM_sources
- awesome quant
- various APIs
- useful sources: Energy Information Administration (EIA), treasury
- additional: IMF, census, UN Comm(odity)Trade,
- datareader
internet archive (Adapter)- need better text integration with plots
- hindenburg
- headline: https://hindenburgresearch.com/
- treasury, additional frb sites
- macromicro / trading economics
- jpm global pmi: https://en.macromicro.me/series/20151/jp-morgan-global-manufacturing-pmi
- jpm global pmi: https://tradingeconomics.com/world/manufacturing-pmi
- quandl / nasdaq data link
- some is free
- api wrapper: https://github.com/Nasdaq/data-link-python
- data: https://data.nasdaq.com/search?filters=%5B%22Free%22%5D
- finplot
- fixed income
- equities
- economics
- altair graphs
- repo: https://github.com/vega/altair
- candlestick
- deep understanding of candlestick
- legend select
- side charts
- update after creation
- ~~shaded regions and recession bars: ~~
- ggplot, plotnine
- metric file storage, PyStore
- update with pyarrow
- original: https://aroussi.com/post/fast-datastore-for-pandas-time-series-data
- Wrapper adapters and source extractors
- plot digitizers