Skip to content

@mostlyrightmd/economy

Raised when a ticker is not a string or matches no routing root.

A named subclass (mirrors the NHIGH/NLOW ContractIdError) so callers can instanceof-check rather than parse the message. Mirrors the Python TypeError / ValueError distinction with a single explicit error — an unroutable ticker is NEVER a silent null return.

  • ContractError

new EconomyTickerError(message): EconomyTickerError

string

EconomyTickerError

ContractError.constructor

A machine-readable divergence event — emitted (and passed to onDivergence) when a TE-settled series ships the agency first-print proxy. Mirrors the Python DivergenceWarning intent: the consumer knows the pair’s value is the agency proxy, NOT the (unlicensed) Trading Economics settlement truth.

readonly contract: string

The matched Kalshi series root (e.g. "KXUSPPI").

readonly indicator: string

The economy indicator id.

readonly message: string

Human-readable message.

readonly settlementAuthority: string

The contractual settlement authority ("TradingEconomics").


indicator: string

indicator id: cpi | cpi_core | cpi_yoy | nfp | u3 | gdp | ppi | ppi_yoy | jobless_claims | fed_funds

knowledge_time: string

leakage cutoff; equals vintage_time for economy (research_economy wires leakage on this)

period: string

observation period the value refers to: ‘2026-06’ monthly, ‘2026Q2’ quarterly, ‘2026-06-28’ weekly/date, or FOMC meeting date

optional release_datetime: null | string

wall-clock the value was released (8:30 ET etc.), UTC

release_type: "final" | "preliminary" | "second" | "advance" | "benchmark" | "revised" | "third"

advance | second | third | final | revised | benchmark | preliminary

optional released_value: null | number

released numeric value; nullable — a not-yet-released period may be schema-shaped but valueless

optional retrieved_at: null | string

provenance of the fetch, UTC

optional series_id: null | string

upstream series identifier (BLS/FRED/BEA code) when applicable

settlement_grade: boolean

is this vintage the settlement truth (first print as-of expiration); False for later vintages AND the 48 TE-settled series

source: string

per-row source identity == df.attrs[‘source’]; one of ECONOMY_SOURCES

optional units: null | string

index | percent | thousands_persons | percent_saar | …

vintage_time: string

WHEN this value became known (ALFRED realtime_start / release-day capture); the leakage knowledge_time


A settlement pair — the first-print observation row plus the resolved market-outcome metadata. The CONTRACT-level grade is written to BOTH the canonical snake_case schema field settlement_grade (overwriting the inherited agency vintage grade — C3) and its camelCase alias settlementGrade; both read false for a TE-settled series even though the agency first print is a real vintage. It is the honest label a model reads to know whether the value IS the settlement truth. knowledge_time (= vintage_time) is the leakage cutoff.

readonly agency: string

The resolved settlement agency short name.

readonly contract: string

The matched Kalshi series ROOT ticker.

indicator: string

indicator id: cpi | cpi_core | cpi_yoy | nfp | u3 | gdp | ppi | ppi_yoy | jobless_claims | fed_funds

EconomyObservationRow.indicator

knowledge_time: string

leakage cutoff; equals vintage_time for economy (research_economy wires leakage on this)

EconomyObservationRow.knowledge_time

period: string

observation period the value refers to: ‘2026-06’ monthly, ‘2026Q2’ quarterly, ‘2026-06-28’ weekly/date, or FOMC meeting date

EconomyObservationRow.period

optional release_datetime: null | string

wall-clock the value was released (8:30 ET etc.), UTC

EconomyObservationRow.release_datetime

release_type: "final" | "preliminary" | "second" | "advance" | "benchmark" | "revised" | "third"

advance | second | third | final | revised | benchmark | preliminary

EconomyObservationRow.release_type

optional released_value: null | number

released numeric value; nullable — a not-yet-released period may be schema-shaped but valueless

EconomyObservationRow.released_value

optional retrieved_at: null | string

provenance of the fetch, UTC

EconomyObservationRow.retrieved_at

optional series_id: null | string

upstream series identifier (BLS/FRED/BEA code) when applicable

EconomyObservationRow.series_id

settlement_grade: boolean

is this vintage the settlement truth (first print as-of expiration); False for later vintages AND the 48 TE-settled series

EconomyObservationRow.settlement_grade

readonly settlementGrade: boolean

Contract-level settlement grade (false for TE-settled series) — a camelCase alias of the canonical settlement_grade; both carry the same value.

source: string

per-row source identity == df.attrs[‘source’]; one of ECONOMY_SOURCES

EconomyObservationRow.source

optional units: null | string

index | percent | thousands_persons | percent_saar | …

EconomyObservationRow.units

vintage_time: string

WHEN this value became known (ALFRED realtime_start / release-day capture); the leakage knowledge_time

EconomyObservationRow.vintage_time


A resolved Kalshi economy settlement mapping.

Mirrors the Python EconomyResolution fields (camelCase). contractTermsUrl is derived from the routing rule’s contractTermsPdf basename (the trusted routing companion to the agency NAME).

readonly agency: string

Canonical settlement agency short name (BLS / BEA / DOL / FederalReserve / TradingEconomics).

readonly contractTermsUrl: null | string

The CFTC contract-terms PDF URL for the series, when known.

readonly indicator: string

Economy indicator id (schema.economy.observations.v1 vocabulary).

readonly root: string

The matched Kalshi series ROOT ticker (e.g. "KXUSPPIYOY").

readonly settlementGrade: boolean

true when the agency first print IS the settlement truth; false for the Trading-Economics-settled series (the agency first print ships as a labeled proxy — a TE value is NEVER fabricated).


readonly agency: string

readonly contractTermsPdf: string

readonly indicator: string

readonly settlementGrade: boolean


One scheduled release of an economy indicator.

readonly agency: string

The source agency short name (BLS / BEA / DOL / FederalReserve).

readonly indicator: string

The economy indicator id.

readonly period: string

The observation period this release publishes ("2026-06" / "2026Q2" / a date).

readonly releaseDatetime: string

The scheduled release wall-clock, tz-aware UTC ISO (8:30 ET → 12:30 UTC).


optional asOf: TimePoint

Optional leakage cutoff. When given, any pair whose knowledge_time (vintage_time) is after asOf throws LeakageError — a future revision can never leak into research.

optional delivery: EconomyDelivery

Where the computation runs (contract §2), forwarded to series. "live" (default) | "hosted" (reserved seam → SourceUnavailableError).

optional fetchRows: FetchRows

Injected fetcher (tests / custom transport), forwarded to series.

optional onDivergence: (warning) => void

Optional structured divergence handler. Invoked with the DivergenceWarning for a TE-settled series so a consumer can branch programmatically. This is the ONLY divergence side-channel — researchEconomy writes nothing to the console (L1); a consumer that wants a log emits one here.

DivergenceWarning

void

optional source: EconomySource

Provenance pin (source-identity contract §1), forwarded to the underlying series read. undefined (default) uses the per-indicator default routing; an unknown source or a valid authority that cannot serve the resolved indicator throws pre-fetch. Whether to also add an includeEconomy covariate seam to core’s dataset() is an OPTION-B question deferred to review — this function does NOT touch core.


optional delivery: EconomyDelivery

Where the computation runs (contract §2). "live" (default) hits the public agency APIs; "hosted" is the reserved precomputed-API seam and throws SourceUnavailableError naming MOSTLYRIGHT_ECONOMY_HOSTED_URL + MOSTLYRIGHT_API_KEY.

optional fetchRows: FetchRows

Injected fetcher (tests / custom transport). When omitted, the default agency dispatch (BLS latest-revised + ALFRED first-print) is used — the live path exercised in the smoke.

optional signal: AbortSignal

Caller abort signal, propagated to every agency fetch (and composed with each attempt’s retry backoff wait). An abort mid-flight rejects promptly with the platform AbortError — never reclassified as a transport error. Ignored when fetchRows is injected (the caller owns that transport).

optional source: EconomySource

Provenance pin (contract §1). undefined (default) uses the per-indicator default routing; a pin names the authority. An unknown source, OR a valid authority that cannot serve indicator (e.g. source: "bea" for "cpi"), throws BEFORE any fetch — never a silent fallback.

optional vintages: Vintages

"settlement" (default) → settlement-grade first-print rows; "all" → every vintage.


optional asOf: Date

The knowledge-time cutoff. Only vintages whose vintage_time is at or before asOf are considered. Defaults to now — the current settlement-target state.

optional delivery: EconomyDelivery

Where the computation runs (contract §2), forwarded to series.

optional fetchRows: FetchRows

Injected fetcher (tests / custom transport), forwarded to series.

indicator: string

The indicator id (schema.economy.observations.v1 vocabulary).

optional source: EconomySource

Provenance pin (contract §1), forwarded to series.

EconomyDelivery: "live" | "hosted"

Accepted delivery= values (contract §2).


EconomyObservationRow: EconomyObservationsV1

One economic-indicator observation row (a schema.economy.observations.v1 record).


EconomySource: "fred" | "bls" | "bea" | "dol" | "fed"

Accepted source= provenance authorities (contract §1).


FetchRows: (indicator, fromDate, toDate) => Promise<EconomyObservationRow[]>

A function that returns the raw schema.economy.observations.v1 rows for a window.

string

Date

Date

Promise<EconomyObservationRow[]>


HistoryOptions: SeriesOptions

Back-compat alias — history accepts the same options as series.


Vintages: "settlement" | "all"

Vintage-selection mode.

const ECONOMY_AGENCY_NAMES: ReadonlyArray<string>


const FEDS_FIRST_CONTRACT: Readonly<Record<string, string>>

FEDS-2026-010 Table 1 first-contract dates (YYYY-MM-DD), keyed on the economy indicator vocabulary. A request below a key’s date is out-of-range. PPI / CPI-Core / jobless-claims floors are Kalshi-inception-derived (not FEDS Table-1 rows), conservatively aligned to the nearest FEDS-dated BLS analog — matching the Python table exactly (tighten if a dated first contract is later confirmed).


const FRED_SERIES_BY_INDICATOR: Readonly<Record<string, string>>


const SETTLEMENT_ROUTING: Readonly<Record<string, EconomySettlementRule>>


const version: "1.9.9" = "1.9.9"

Public package version; kept in lockstep with package.json.

assertWithinFloor(indicator, fromDate): void

Throw DataAvailabilityError (reason: "out_of_window") when fromDate predates indicator’s FEDS first-contract floor, or when indicator is unknown (never silently passes). Returns void when fromDate is at/after the floor. Mirrors the Python assert_within_floor.

string

An economy indicator key (must be a key of FEDS_FIRST_CONTRACT).

Date

The inclusive start of the requested research range (compared at UTC-day granularity — the time component is dropped).

void


history(indicator, fromDate, toDate, options): Promise<DataResult<EconomyObservationsV1>>

Deprecated alias of series — returns byte-identical output.

string

Date

Date

SeriesOptions = {}

Promise<DataResult<EconomyObservationsV1>>

Use series. history is retained as a working alias (plan conformed the economy surface to the cross-vertical source-identity contract). It emits NO runtime warning this release — matching the research/dataset silent-alias style. A deprecation lands in the next minor; removal at 2.0. All arguments forward verbatim to series; see its docs for the full contract (vintages, source, delivery).


kalshiEconomyResolve(seriesTicker): EconomyResolution

Resolve a Kalshi economy ticker to its (root, settlement mapping).

Matching is exact-then-longest-prefix (identical to the Python resolver):

  1. Exact match on the full (uppercased) ticker, else
  2. the LONGEST SETTLEMENT_ROUTING root that ticker starts with.

string

A Kalshi economy series root ("KXCPIYOY") or a concrete dated market ticker ("KXCPIYOY-26JUL"). Case-insensitive.

EconomyResolution

A frozen EconomyResolution.

seriesTicker is not a string, or matches no root.


releases(indicator): ReleaseEvent[]

Return the release calendar / schedule for indicator, sorted ascending by releaseDatetime. Sourced from the curated v1 schedule table (a live agency-calendar fetch is a documented fast-follow).

string

ReleaseEvent[]

indicator is not a string.

indicator has no known schedule (never returns []/null).


researchEconomy(seriesOrContract, fromDate, toDate, options): Promise<EconomyPairRow[]>

Return leakage-free settlement pairs for seriesOrContract.

Each pair joins the market outcome (resolved agency/indicator/settlement metadata) to the first-print indicator value and the as-of features known at knowledge_time = vintage_time — safe in research and live.

string

A Kalshi economy series root ("KXCPIYOY") or a concrete dated market ticker ("KXCPIYOY-26JUL"). Case-insensitive.

Date

Inclusive start of the requested range.

Date

Inclusive end of the requested range.

ResearchEconomyOptions = {}

asOf (leakage cutoff), fetchRows, onDivergence.

Promise<EconomyPairRow[]>

The settlement pairs (object array — no DataFrame).

the ticker resolves to no routing root.

the indicator’s window is below the FEDS floor.

the settlement period has no first print yet.

an asOf was given and a pair’s vintage_time is after it.


series(indicator, fromDate, toDate, options): Promise<DataResult<EconomyObservationsV1>>

Return economic-indicator observation rows for indicator (canonical read).

string

The indicator id (schema.economy.observations.v1 vocabulary: "cpi" / "nfp" / "gdp" / "ppi" / "jobless_claims" / …).

Date

Inclusive start of the requested range.

Date

Inclusive end of the requested range.

SeriesOptions = {}

vintages ("settlement" default | "all"), source (contract §1 pin), delivery (contract §2), + an optional injected fetchRows.

Promise<DataResult<EconomyObservationsV1>>

The observation rows (object array — the TS SDK convention; no DataFrame).

vintages/source/delivery is invalid (source/delivery validated BEFORE any fetch).

delivery: "hosted" (the reserved seam).

fromDate is below the indicator’s FEDS floor, or the indicator is unknown.

the window has no relevant rows — a scheduled release has not landed yet. NEVER returns []/null.


snapshot(options): Promise<DataResult<EconomyObservationsV1>>

Return the settlement-target state of indicator as knowable at asOf.

SnapshotOptions

indicator (required), asOf (default now), source, delivery, fetchRows.

Promise<DataResult<EconomyObservationsV1>>

The { rows, provenance } envelope (the same DataResult<Row> series/history return): one settlement-grade row per period knowable at asOf (the latest such vintage per period), with provenance byte-identical to the composed series read (same schema_id, source stamped from the rows).

an invalid source/delivery (pre-fetch) — see series.

delivery: "hosted" (the reserved seam).

indicator is unknown (no FEDS floor).

nothing is knowable at asOf — no settlement-grade vintage exists at or before the cutoff. NEVER returns []/null.