Repair every dead series-ID encoding (library now 82/82 query helpers
return live data, verified against the BLS API):
- JOLTS: 21-char format (was 18) — add state/area/sizeclass fields
- OES: national area code 0000000 (was invalid 0000400)
- ECI: correct owner/component/estimate encoding, default unadjusted (CIU)
- Productivity: 4-digit sector + 4-digit measure codes (was 2+3)
- QCEW: 13-char timeseries-API form (ENUUS00010510 / ENU{fips}00010{own}10)
- PPI: repoint finished-goods -> final demand (WPUFD4); keep alias
- ECEC: drop fabricated health-insurance/retirement helpers; add total benefits
- wages SOC: software developers 151132 -> 151252 (2018 SOC)
Tooling/docs:
- config reads BLS_API_KEY env var (takes precedence; config.py gitignored)
- add requirements.txt
- rewrite README as project front door + coverage table + limitations
- correct JOLTS/OES tables in series_id_formats.md, USAGE.md, dataset explorer
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
129 lines
3.7 KiB
Python
129 lines
3.7 KiB
Python
"""
|
|
Pre-built price series IDs — CPI, PPI, Import/Export, Average Prices.
|
|
"""
|
|
|
|
from ..series import cpi, ppi_commodity
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# CPI-U
|
|
# ---------------------------------------------------------------------------
|
|
def cpi_all_items(seasonal: bool = False) -> str:
|
|
"""CPI-U all items, US city average."""
|
|
return cpi("all_items", seasonal=seasonal)
|
|
|
|
|
|
def cpi_core(seasonal: bool = True) -> str:
|
|
"""CPI-U all items less food and energy (core inflation)."""
|
|
return cpi("core", seasonal=seasonal)
|
|
|
|
|
|
def cpi_food(seasonal: bool = False) -> str:
|
|
return cpi("food", seasonal=seasonal)
|
|
|
|
|
|
def cpi_energy(seasonal: bool = False) -> str:
|
|
return cpi("energy", seasonal=seasonal)
|
|
|
|
|
|
def cpi_shelter(seasonal: bool = False) -> str:
|
|
return cpi("shelter", seasonal=seasonal)
|
|
|
|
|
|
def cpi_gasoline(seasonal: bool = True) -> str:
|
|
return cpi("gasoline", seasonal=seasonal)
|
|
|
|
|
|
def cpi_medical(seasonal: bool = False) -> str:
|
|
return cpi("medical", seasonal=seasonal)
|
|
|
|
|
|
def cpi_dashboard(seasonal: bool = False) -> dict:
|
|
"""Key CPI components as a labeled dict."""
|
|
return {
|
|
"All Items": cpi_all_items(seasonal),
|
|
"Core (ex food/NRG)": cpi_core(True),
|
|
"Food": cpi_food(seasonal),
|
|
"Energy": cpi_energy(seasonal),
|
|
"Shelter": cpi_shelter(seasonal),
|
|
"Medical Care": cpi_medical(seasonal),
|
|
"Gasoline": cpi_gasoline(True),
|
|
}
|
|
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# CPI-W
|
|
# ---------------------------------------------------------------------------
|
|
def cpi_w_all_items(seasonal: bool = False) -> str:
|
|
"""CPI-W all items (used for Social Security COLA)."""
|
|
return cpi("all_items", seasonal=seasonal, series="W")
|
|
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# PPI
|
|
# ---------------------------------------------------------------------------
|
|
def ppi_all_commodities() -> str:
|
|
"""PPI — all commodities index."""
|
|
return ppi_commodity("00000000")
|
|
|
|
|
|
def ppi_final_demand() -> str:
|
|
"""PPI — final demand (successor to the discontinued 'finished goods' index)."""
|
|
return ppi_commodity("FD4")
|
|
|
|
|
|
# Backwards-compatible alias; the legacy "finished goods" index was replaced by final demand.
|
|
ppi_finished_goods = ppi_final_demand
|
|
|
|
|
|
def ppi_energy() -> str:
|
|
return ppi_commodity("05")
|
|
|
|
|
|
def ppi_food() -> str:
|
|
return ppi_commodity("02")
|
|
|
|
|
|
def ppi_dashboard() -> dict:
|
|
return {
|
|
"All Commodities": ppi_all_commodities(),
|
|
"Final Demand": ppi_final_demand(),
|
|
"Food": ppi_food(),
|
|
"Energy": ppi_energy(),
|
|
}
|
|
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Average Prices (AP)
|
|
# ---------------------------------------------------------------------------
|
|
def avg_price_electricity() -> str:
|
|
"""Average retail price of electricity per KWh."""
|
|
return "APU000072610"
|
|
|
|
|
|
def avg_price_gasoline_regular() -> str:
|
|
"""Average retail price of regular unleaded gasoline per gallon."""
|
|
return "APU00007471A"
|
|
|
|
|
|
def avg_price_eggs() -> str:
|
|
"""Average retail price of eggs per dozen."""
|
|
return "APU0000708111"
|
|
|
|
|
|
def avg_price_ground_beef() -> str:
|
|
"""Average retail price of ground beef per pound."""
|
|
return "APU0000703112"
|
|
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Import/Export Price Indexes (EI)
|
|
# ---------------------------------------------------------------------------
|
|
def import_price_index() -> str:
|
|
"""Import price index — all imports."""
|
|
return "EIUIR"
|
|
|
|
|
|
def export_price_index() -> str:
|
|
"""Export price index — all exports."""
|
|
return "EIUIQ"
|