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()) 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 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: this resolver reads only the pre-curated agency
names in SETTLEMENT_ROUTING. It never fetches or parses the
Kalshi-supplied settlement-source URL field carried in 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 routing uses the name only, from the curated table.
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 produced by the economy package.
Functions
Section titled “Functions”| Function | Description |
|---|---|
resolve(ticker) | Resolve a Kalshi Economics ticker to its settlement mapping. |
Classes
Section titled “Classes”| Class | Description |
|---|---|
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 eleven
AGENCY_NAMES. Six are
US-facing ("BLS" / "BEA" / "DOL" /
"FederalReserve" / "FRED" / "TradingEconomics") and five
are the reference-area publishers ("ONS" / "StatCan" /
"ECB" / "Eurostat" / "ABS"; "BIS" names the
policy-rate compiler). Routed on the Kalshi settlement-source name,
never the URL. The name is the PUBLISHER the rule claims, which is
not always the transport: euro-area HICP names "Eurostat" while
its rows carry source="ecb.sdmx".
indicator
Section titled “indicator”The economy indicator id (same vocabulary as
schema.economy.observations.v1). US ids are bare (cpi /
cpi_core / cpi_yoy / nfp / u3 / gdp / ppi /
ppi_yoy / jobless_claims / fed_funds / …); every other
reference area prefixes its own (uk.cpi_yoy / ca.cpi_yoy /
ea.policy_rate / au.cpi / …).
settlement_grade
Section titled “settlement_grade”True when the agency first print IS the settlement
truth. False covers two distinct cases now, and the label is the
same because the caller’s exposure is: the value returned is not the
one the contract settles on, and it is labeled rather than
fabricated. (1) A vendor-settled series, where the agency’s own
print stands in for the source the exchange names — no Trading
Economics value is ever invented. (2) A route with no as-published
archive, where the publisher IS the one the exchange names but only
the latest revision is recoverable — every ea.* rule is this
case, including the two the exchange settles on the ECB and Eurostat
themselves.
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
agency 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. For a contract the SDK has examined and deliberately not routed (a central-bank decision, a proprietary print, a European Union underlying), the message is that contract’s reason fromNOT_ROUTED_REASONS; otherwise it names the ticker and the known roots. Never returnsNone— an unroutable ticker is an explicit error, not a silent default to some agency.
- TypeError –