mostlyright.markets.catalog.kalshi_economy
Kalshi Economics contract resolver (per-series agency-NAME routing).
Kalshi Economics markets (CPI, PPI, NFP, GDP, jobless claims, Fed decision, …)
each settle against a specific agency’s first print. resolve(ticker)
is the deterministic mapping from a Kalshi Economics series/contract ticker to
an EconomyResolution (agency, indicator, settlement_grade, contract_terms_url) tuple that downstream code (research_economy(), plan
) uses to join the correct agency first-print row.
It mirrors mostlyright.markets.catalog.kalshi_nhigh — a frozen-dataclass
result plus a deterministic resolve() with an up-front type guard, a
ValueError on unknown tickers (it NEVER returns None), and a
__all__ of [ResultClass, "resolve"].
Routing is genuinely PER-SERIES, driven by the curated
SETTLEMENT_ROUTING table — keyed on
canonical Kalshi series ROOT tickers and the agency NAMES those roots settle to.
The load-bearing case is the PPI family split: KXUSPPI (PPI MoM) settles to
Trading Economics at settlement_grade=False while its sibling
KXUSPPIYOY (PPI YoY) settles to BLS at settlement_grade=True. Assuming
“the government first print” for the 48 Trading-Economics-settled series
(KXUSPPI, KXUSNFP, and international variants) would mis-settle every one
of them.
SSRF / sloppy-URL firewall (; STRIDE): this resolver reads
ONLY the pre-curated agency NAMES in SETTLEMENT_ROUTING. It NEVER fetches or
parses the Kalshi-supplied settlement-source URL field handed to us by series
metadata — those URLs are demonstrably wrong live (KXPAYROLLS carries
name="BLS" but a URL pointing at ppi.nr0.htm; one series’ URL points at
“San Francisco Unified School District”). Routing on the URL would settle NFP
contracts against PPI data. So: NAME only, from the curated table. (The literal
Kalshi field name is deliberately kept out of this module so the CI grep gate
that asserts “no URL routing” stays green.)
ECONOMY-17: for a Trading-Economics-settled series the resolver only labels
settlement_grade=False. It structurally cannot emit a fabricated Trading
Economics number — EconomyResolution carries no value field; the value
stays the agency first-print in the data layer.
Functions
Section titled “Functions”resolve(ticker) | Resolve a Kalshi Economics ticker to its settlement mapping. |
|---|
Classes
Section titled “Classes”EconomyResolution(agency, indicator, …) | The settlement mapping a Kalshi Economics contract resolves to. |
|---|
class mostlyright.markets.catalog.kalshi_economy.EconomyResolution(agency, indicator, settlement_grade, contract_terms_url)
Section titled “class mostlyright.markets.catalog.kalshi_economy.EconomyResolution(agency, indicator, settlement_grade, contract_terms_url)”Bases: object
The settlement mapping a Kalshi Economics contract resolves to.
agency
Section titled “agency”The canonical settlement-agency short name — one of the five
AGENCY_NAMES
("BLS" / "BEA" / "DOL" / "FederalReserve" /
"TradingEconomics"). Routed on the Kalshi settlement-source
NAME, never the URL.
indicator
Section titled “indicator”The economy indicator id (same vocabulary as
schema.economy.observations.v1: cpi / cpi_core /
cpi_yoy / nfp / u3 / gdp / ppi / ppi_yoy /
jobless_claims / fed_funds / …).
settlement_grade
Section titled “settlement_grade”True when the agency first print IS the
settlement truth; False for the 48 Trading-Economics-settled
series (the agency first print ships as a labeled proxy — no TE
value is ever fabricated; ECONOMY-17).
contract_terms_url
Section titled “contract_terms_url”The trusted CFTC contract-terms PDF basename from
the routing rule (e.g. "CPI.pdf"), or "" when the routing
rule carries no PDF. This is a curated routing companion to the
NAME — it is NEVER a fetched or Kalshi-supplied settlement-source
URL.
agency: str
Section titled “agency: str”contract_terms_url: str
Section titled “contract_terms_url: str”indicator: str
Section titled “indicator: str”settlement_grade: bool
Section titled “settlement_grade: bool”mostlyright.markets.catalog.kalshi_economy.resolve(ticker)
Section titled “mostlyright.markets.catalog.kalshi_economy.resolve(ticker)”Resolve a Kalshi Economics ticker to its settlement mapping.
- Parameters:
ticker (
str) – A Kalshi Economics series root ("KXCPIYOY") or a concrete dated market ticker ("KXCPIYOY-26JUL"). Case-insensitive. - Return type:
EconomyResolution - Returns:
The
EconomyResolutionfor the matched routing rule. - Raises:
- TypeError –
tickeris not astr(mirrors kalshi_nhigh’s up-front type guard). - ValueError –
tickermatches no known routing root. The message names the ticker and the known roots (never returnsNone— an unroutable ticker is an explicit error, not a silent default to some agency).
- TypeError –