Reproducible pipeline for computing the Tariff Exposure Propagation Index (TEPI) across the 2025–2026 U.S. tariff shock and reversal.
This codebase backs the IEOM Milwaukee 2026 paper:
A Tariff Exposure Propagation Index for Measuring Hidden Supply-Chain Vulnerability: Evidence from the 2025–2026 U.S. Shock and Reversal
The pipeline pulls public data (Census trade, BEA input-output, FRED freight, NY Fed GSCPI, SEC EDGAR, USITC tariff schedules, and equity returns), constructs a three-regime tariff panel (baseline, IEEPA, post-reversal/Section 122), computes TEPI at the BEA detailed industry level, runs three independent validations, and emits paper-ready tables and figures.
# 1. Install
pip install -e .
# 2. Configure API keys (free) in config/api_keys.yaml
# - census_api_key: https://api.census.gov/data/key_signup.html
# - fred_api_key: https://fred.stlouisfed.org/docs/api/api_key.html
# - sec_user_agent: "Your Name your.email@example.org"
# 3. Run the full pipeline
python -m tepi run-all
# Or run individual stages
python -m tepi ingest # Pull all raw data
python -m tepi transform # Build crosswalk + 3-regime panel
python -m tepi index # Compute TEPI
python -m tepi validate # Run CAR / IP / 10-K validations
python -m tepi tables # Build paper-ready tables and figuresThe Census stage fetches ~4 365 API requests (45 months × 97 HS chapters). Run it separately with higher concurrency to finish in minutes instead of hours:
# Recommended: 25 concurrent requests — completes the full window in ~6 minutes
python -m tepi ingest-census --concurrency 25
# Fetch one year at a time (useful if the API is flaky)
python -m tepi ingest-census --year 2024 --concurrency 25
# Fetch a single month
python -m tepi ingest-census --year 2024 --month 6 --concurrency 25
# Re-fetch a month that came back empty or errored
python -m tepi ingest-census --year 2024 --month 6 --force --concurrency 25Each completed month is saved as a checkpoint file under
data/raw/census_imports/months/. If a run is interrupted, restarting picks up
from where it left off — already-fetched months are skipped automatically.
Once Census is complete, run the remaining ingest stages (FRED, GSCPI, BEA):
python -m tepi ingestCensus will immediately skip because all checkpoints exist; FRED, GSCPI, and BEA then run normally.
All runs write a timestamped log file to logs/tepi_YYYYMMDD_HHMMSS.log in
addition to console output. Use --log-dir to change the location.
- ingest — Pull HS-10 trade data (Census), tariff schedules (USITC + Federal Register), I-O tables (BEA), freight indices (FRED), GSCPI (NY Fed), 10-K filings (SEC EDGAR), and equity returns (yfinance).
- transform — Build HS→NAICS→BEA crosswalk, construct three-regime tariff panel, residualize controls.
- index — Compute D_it (direct), P_it (propagated), ρ_i (snapback), TEPI_it (composite).
- validate — Three independent tests: equity CARs around Feb 20 2026 ruling, industrial production response during IEEPA period, 10-K text exposure scoring. Plus services-sector falsification check.
- tables — Generate Tables 1–5 and Figures 1–4 in paper-ready formats (CSV, LaTeX, PNG, PDF).
Every stage is idempotent and writes to data/processed/ with a manifest
including data vintages, parameter values, and a content hash. Re-running
without changes is a no-op. Re-running after upstream data revisions
re-computes only the affected downstream stages.
pytest # Unit tests with mock data
pytest --integration # Integration tests (needs API keys)Code: MIT. Outputs (TEPI panel, crosswalk, replication bundle): CC-BY 4.0.