@mostlyrightmd/econ
v1.17.0
Published
Economic-indicator data for TypeScript / Node — CPI, PPI, nonfarm payrolls (NFP), U3 unemployment, initial jobless claims, GDP, and Fed decisions, joined to Kalshi + Polymarket econ markets for leakage-free settlement pairs. First-print / ALFRED vintage d
Maintainers
Readme
@mostlyrightmd/econ
Economic-indicator data for the mostlyright TypeScript SDK — CPI (headline / core / YoY), PPI, nonfarm payrolls (NFP), U3 unemployment, initial jobless claims, GDP, and Fed decisions, sourced from FRED/ALFRED + BLS/BEA/DOL/Federal Reserve and joined to Kalshi + Polymarket econ markets for leakage-free settlement pairs. Mirrors the Python mostlyrightmd-econ distribution surface. Declares @mostlyrightmd/core as a peer dependency.
Install
pnpm add @mostlyrightmd/econ @mostlyrightmd/coreSurface
Surface-equivalent to the Python mostlyright.econ vertical (camelCase TS signatures):
history(indicator, fromDate, toDate, { vintages })— observation rows.vintages: "settlement"(default) returns the settlement-grade first print (the value as-of the Kalshi expiration);vintages: "all"returns every vintage for feature engineering.releases(indicator)— the release calendar / schedule for an indicator.researchEcon(seriesOrContract, fromDate, toDate, { asOf })— leakage-free settlement pairs (market outcome + first-print value + as-of features). WhenasOfis given, any pair whoseknowledge_time(=vintage_date) is after it throwsLeakageError— a future revision can never leak into a backtest.
Load-bearing invariants (parity with Python)
- First-print / ALFRED vintage discipline. Kalshi settlements contractually exclude post-expiration revisions; the backtest layer serves as-released vintages, never the revised series. Vintage selection happens at read time via
vintages. - Per-series settlement routing. 48 of the Kalshi Economics series settle to Trading Economics, not the government agency (incl.
KXUSPPIPPI-MoM,KXUSNFP). Routing is genuinely per-series:KXUSPPI(MoM) → TradingEconomics, butKXUSPPIYOY(YoY) → BLS. The routing table is codegen-shared fromschemas/kalshi-econ-settlement.json(the Python↔TS anti-drift gate). - TE-settled series are honest, never fabricated. For a Trading-Economics-settled series,
researchEconships the agency first print labeledsettlementGrade=falseand emits a divergence warning — it NEVER fabricates a TE value. IndicatorNotYetReleasedError, not[]/null. "Not yet released" is a normal, branchable control state distinct from "unavailable". The error is re-exported from@mostlyrightmd/core(Python↔TS lockstep taxonomy).- Parity firewall. Econ never registers into the TS
research()/ merge / live-source equivalents — an econ row must never reach the weather settlement join (the same isolation the Python vertical and CWOP use).
Browser / Node constraints
The fetch layer uses the standard fetch API and JSON — no Node-only API on a browser-viable path (mirrors the weather TS browser-safe boundary). API keys (FRED_API_KEY / BLS_API_KEY for ALFRED / BLS-v2) are read from the Node environment only; they are never bundled into a browser build.
Schema
The EconObservationRow (schema.econ.observations.v1) column types are codegen-derived from the shared JSON via @mostlyrightmd/codegen — never hand-written in TS. Regenerate with pnpm codegen.
Docs
See https://mostlyright.md/docs/sdk/ for quickstart and the full API reference.
