@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 / lo > hi. A ContractError
subclass (DX-H5): a bad ticker is an invalid local call, not a transport
failure — it is 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”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”
readonlycity:string
The 3-letter catalog city key (e.g. NYC) — alias-resolved.
readonlykind:KalshiStrikeKind
"threshold" (-T<n>) or "range" (-B<lo>-<hi>).
lowerStrike?
Section titled “lowerStrike?”
readonlyoptionallowerStrike:number
Range bounds (present when kind === "range").
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).
strike?
Section titled “strike?”
readonlyoptionalstrike:number
Threshold strike (present when kind === "threshold").
upperStrike?
Section titled “upperStrike?”
readonlyoptionalupperStrike:number
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
KalshiStrikeKind
Section titled “KalshiStrikeKind”KalshiStrikeKind:
"threshold"|"range"
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:"1.9.9"="1.9.9"
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/strike + resolve the settlement station via the parity-critical whitelist (with the NY→NYC alias on a raw-suffix miss).
Parameters
Section titled “Parameters”ticker
Section titled “ticker”string
Returns
Section titled “Returns”Throws
Section titled “Throws”malformed ticker, unknown city, or lo > hi.
settleKalshiOutcome()
Section titled “settleKalshiOutcome()”settleKalshiOutcome(
parsed,observed):null|0|1
Settle an observed value against a parsed Kalshi ticker’s strike.
INCLUSIVE comparison (documented, see file header + -SUMMARY.md) threshold: value >= strike; range: lo <= value <= hi.
Parameters
Section titled “Parameters”parsed
Section titled “parsed”observed
Section titled “observed”null | number
Returns
Section titled “Returns”null | 0 | 1
1 (YES), 0 (NO), or null when observed is null (NaN label → NA
outcome, row preserved — mirrors Python).