@mostlyrightmd/markets
Classes
Section titled “Classes”ContractIdError
Section titled “ContractIdError”Custom error type for contract-id parsing / validation failures.
Mirrors the Python ValueError/TypeError distinction: in TS we use a
named subclass so callers can instanceof-check rather than parse
error messages.
Extends
Section titled “Extends”ContractError
Constructors
Section titled “Constructors”new ContractIdError()
Section titled “new ContractIdError()”new ContractIdError(
message):ContractIdError
Parameters
Section titled “Parameters”message
Section titled “message”string
Returns
Section titled “Returns”Overrides
Section titled “Overrides”ContractError.constructor
KalshiTickerError
Section titled “KalshiTickerError”Raised on a malformed ticker / unknown city, or on absent/unsupported settlement metadata. A ContractError subclass: an invalid local call, not a transport failure — raised before any I/O.
Extends
Section titled “Extends”ContractError
Constructors
Section titled “Constructors”new KalshiTickerError()
Section titled “new KalshiTickerError()”new KalshiTickerError(
message):KalshiTickerError
Parameters
Section titled “Parameters”message
Section titled “message”string
Returns
Section titled “Returns”Overrides
Section titled “Overrides”ContractError.constructor
Interfaces
Section titled “Interfaces”KalshiMarketMetadata
Section titled “KalshiMarketMetadata”The Kalshi GetMarket object shape (snake_case wire form) — the settlement
metadata the caller supplies. Fetch it via fetchMarket(ticker) (./trades)
and pass it to settleKalshiOutcome.
Properties
Section titled “Properties”cap_strike?
Section titled “cap_strike?”
readonlyoptionalcap_strike:null|string|number
floor_strike?
Section titled “floor_strike?”
readonlyoptionalfloor_strike:null|string|number
result?
Section titled “result?”
readonlyoptionalresult:string
strike_type?
Section titled “strike_type?”
readonlyoptionalstrike_type:string
KalshiStation
Section titled “KalshiStation”Properties
Section titled “Properties”citation
Section titled “citation”citation:
string
station
Section titled “station”station:
string
NHighResolution
Section titled “NHighResolution”Properties
Section titled “Properties”cityTicker
Section titled “cityTicker”
readonlycityTicker:string
contractDate
Section titled “contractDate”
readonlycontractDate:string
settlementSource
Section titled “settlementSource”
readonlysettlementSource:"cli.archive"
settlementStation
Section titled “settlementStation”
readonlysettlementStation:string
NLowResolution
Section titled “NLowResolution”Properties
Section titled “Properties”cityTicker
Section titled “cityTicker”
readonlycityTicker:string
contractDate
Section titled “contractDate”
readonlycontractDate:string
settlementSource
Section titled “settlementSource”
readonlysettlementSource:"cli.archive"
settlementStation
Section titled “settlementStation”
readonlysettlementStation:string
ParsedKalshiTicker
Section titled “ParsedKalshiTicker”Properties
Section titled “Properties”capStrike?
Section titled “capStrike?”
readonlyoptionalcapStrike:number
readonlycity:string
The 3-letter catalog city key (e.g. NYC) — alias-resolved.
floorStrike?
Section titled “floorStrike?”
readonlyoptionalfloorStrike:number
Numeric settlement bounds from the market payload, else undefined.
measure
Section titled “measure”
readonlymeasure:KalshiMeasure
"high" (KXHIGH*) or "low" (KXLOW*).
series
Section titled “series”
readonlyseries:string
The full series token (e.g. KXHIGHNY).
station
Section titled “station”
readonlystation:string
The resolved settlement station ICAO (e.g. KNYC).
strikeToken
Section titled “strikeToken”
readonlystrikeToken:string
The raw strike token, captured verbatim (T86, B81.5, …) — opaque,
never classified.
strikeType?
Section titled “strikeType?”
readonlyoptionalstrikeType:KalshiStrikeType
The Kalshi strike_type enum — populated only from a supplied market
payload, never inferred from the token.
PolymarketCityStation
Section titled “PolymarketCityStation”Indexable
Section titled “Indexable”[measure: string]: undefined | string
Properties
Section titled “Properties”default
Section titled “default”default:
string
optionalhigh:string
optionallow:string
Type Aliases
Section titled “Type Aliases”KalshiMeasure
Section titled “KalshiMeasure”KalshiMeasure:
"high"|"low"
KalshiSettlement
Section titled “KalshiSettlement”KalshiSettlement:
NHighResolution|NLowResolution
KalshiStrikeType
Section titled “KalshiStrikeType”KalshiStrikeType:
"greater"|"greater_or_equal"|"less"|"less_or_equal"|"between"
The Kalshi strike_type values the settle path maps. functional/custom/
structured are out of scope for weather markets and are refused.
Variables
Section titled “Variables”KALSHI_SETTLEMENT_STATIONS
Section titled “KALSHI_SETTLEMENT_STATIONS”
constKALSHI_SETTLEMENT_STATIONS:Readonly<Record<string,KalshiStation>>
KNOWN_WRONG_STATIONS
Section titled “KNOWN_WRONG_STATIONS”
constKNOWN_WRONG_STATIONS:ReadonlySet<string>
POLYMARKET_CITY_STATIONS
Section titled “POLYMARKET_CITY_STATIONS”
constPOLYMARKET_CITY_STATIONS:Readonly<Record<string,PolymarketCityStation>>
version
Section titled “version”
constversion:"4.1.0"="4.1.0"
Public package version; kept in lockstep with package.json.
Functions
Section titled “Functions”kalshiNhighResolve()
Section titled “kalshiNhighResolve()”kalshiNhighResolve(
ticker,settlementDate):NHighResolution
Resolve a Kalshi NHIGH contract to its settlement source + station.
The contract id format is KHIGH<CITY> (case-insensitive), where
<CITY> is a city ticker present in
KALSHI_SETTLEMENT_STATIONS.
Parameters
Section titled “Parameters”ticker
Section titled “ticker”string
Kalshi market identifier. Case-insensitive.
settlementDate
Section titled “settlementDate”Calendar date the market settles for. Either a
UTC date-only Date (H/M/S/ms == 0) or a YYYY-MM-DD string.
string | Date
Returns
Section titled “Returns”A frozen NHighResolution.
Throws
Section titled “Throws”The contract id doesn’t follow
KHIGH<CITY>, the city is unknown, or the settlement date is
invalid.
kalshiNlowResolve()
Section titled “kalshiNlowResolve()”kalshiNlowResolve(
ticker,settlementDate):NLowResolution
Resolve a Kalshi NLOW contract to its settlement source + station.
The contract id format is KLOW<CITY> (case-insensitive), where
<CITY> is a city ticker present in
KALSHI_SETTLEMENT_STATIONS.
Parameters
Section titled “Parameters”ticker
Section titled “ticker”string
Kalshi market identifier. Case-insensitive.
settlementDate
Section titled “settlementDate”Calendar date the market settles for. Either a
UTC date-only Date (H/M/S/ms == 0) or a YYYY-MM-DD string.
string | Date
Returns
Section titled “Returns”A frozen NLowResolution.
Throws
Section titled “Throws”The contract id doesn’t follow
KLOW<CITY>, the city is unknown, or the settlement date is
invalid.
kalshiSettlementFor()
Section titled “kalshiSettlementFor()”kalshiSettlementFor(
ticker,date):KalshiSettlement
Resolve a Kalshi NHIGH or NLOW contract id to its settlement metadata.
KHIGH* prefixes dispatch to the NHIGH resolver; KLOW* prefixes
dispatch to NLOW. Anything else raises ContractIdError.
Parameters
Section titled “Parameters”ticker
Section titled “ticker”string
string
Returns
Section titled “Returns”Example
Section titled “Example”kalshiSettlementFor("KHIGHNYC", "2025-01-06") // → { settlementSource: "cli.archive", settlementStation: "KNYC", // cityTicker: "NYC", contractDate: "2025-01-06" }parseTicker()
Section titled “parseTicker()”parseTicker(
ticker):ParsedKalshiTicker
Parse a full Kalshi market ticker into series/measure/city + the resolved
settlement station, capturing the strike token verbatim. The parse is
station-only: it never classifies the strike shape or infers a direction, so a
B<midpoint> between ticker (KXHIGHNY-26JUL24-B81.5) parses without
crashing. Settlement semantics come from the market payload
(settleKalshiOutcome(parsed, observed, market)), never this token.
Parameters
Section titled “Parameters”ticker
Section titled “ticker”string
Returns
Section titled “Returns”Throws
Section titled “Throws”malformed anatomy, non-HIGH/LOW series, unknown city, or an empty strike token.
settleKalshiOutcome()
Section titled “settleKalshiOutcome()”settleKalshiOutcome(
parsed,observed,market):null|0|1
Settle an observed value against the market’s strike_type metadata.
Dispatch is on the Kalshi GetMarket strike_type enum, never on the ticker
suffix. Strict open-ends:
greater -> value > floor_strike; less -> value < cap_strike;
between -> floor_strike <= value <= cap_strike.
Parameters
Section titled “Parameters”parsed
Section titled “parsed”The parsed ticker (station/measure identity).
observed
Section titled “observed”The observed settlement value (°F). null → null outcome
(NaN label → NA outcome, row preserved — mirrors Python).
null | number
market
Section titled “market”The Kalshi GetMarket object, supplied by the caller.
undefined | null | KalshiMarketMetadata
Returns
Section titled “Returns”null | 0 | 1
Throws
Section titled “Throws”market metadata absent or strike_type unsupported.