Markets
Validate a contract before requesting settlement data. Kalshi weather contracts resolve against NWS daily climate reports. Supported Polymarket weather events resolve against the station and daily extreme named by the event.
Install
Section titled “Install”pip install mostlyrightmd-marketspnpm add @mostlyrightmd/marketsParse a Kalshi contract
Section titled “Parse a Kalshi contract”Ticker parsing is public and inspectable:
from mostlyright.markets import kalshi
parsed = kalshi.parse_ticker("KXHIGHNY-25MAY26-T79")print(parsed.station, parsed.measure, parsed.strike_token)Ticker parsing resolves the series, city, station, measure, and opaque strike
token. It does not infer settlement direction or bounds from -T79 or another
ticker suffix. Malformed or unsupported tickers raise KalshiTickerError.
TypeScript exposes the same parser and outcome comparison:
import { parseTicker, settleKalshiOutcome } from "@mostlyrightmd/markets";
const parsed = parseTicker("KXHIGHNY-25MAY26-T79");const outcome = settleKalshiOutcome(parsed, 81, { strike_type: "greater", floor_strike: 79, cap_strike: null,});Pass the market’s own GetMarket metadata to the outcome helper. Do not derive it from the displayed ticker.
Kalshi comparisons follow strike_type exactly:
strike_type | YES when |
|---|---|
greater | value > floor_strike |
greater_or_equal | value >= floor_strike |
less | value < cap_strike |
less_or_equal | value <= cap_strike |
between | floor_strike <= value <= cap_strike |
To inspect the settlement dates represented by a ticker:
days = kalshi.settlement_days( "KXHIGHNY-25MAY26-T79", "2025-05-20", "2025-05-26",)Discover and settle a Polymarket event
Section titled “Discover and settle a Polymarket event”Polymarket uses its event id as the entity:
from mostlyright.markets import polymarket
events = polymarket.discover()event_id = events.iloc[0]["event_id"]result = polymarket.settle(event_id)Station resolution remains explicit:
load_polymarket_city_stations()exposes the published city/measure mapping.resolve_station_for_event()resolves an event to the station used for settlement.- guarded unsupported markets raise
DeferredMarketErrorrather than resolving to a knowingly wrong station. - settling before a trustworthy record exists raises
TooEarlyToSettleError.
Strike comparisons
Section titled “Strike comparisons”above settles YES when observed >= strike; below when observed <= strike; between is inclusive at both endpoints. Negative temperatures are parsed deliberately so a separator hyphen is not mistaken for or stripped from a minus sign.
Malformed strike text raises PolymarketStrikeError.
Errors
Section titled “Errors”| Error | When |
|---|---|
KalshiTickerError | A ticker cannot be parsed or is outside the supported settlement universe |
PolymarketStrikeError | An above, below, or between strike cannot be parsed |
PolymarketEventError | An event cannot be validated or fetched |
PolymarketSettlementError | A trustworthy settlement value cannot be established |
TooEarlyToSettleError | Settlement is requested before the record exists |
DeferredMarketError | The event is on a guarded unsupported path |
Discover with TypeScript
Section titled “Discover with TypeScript”import { discover } from "@mostlyrightmd/markets/polymarket";
const events = await discover();Polymarket’s Gamma API allows browser requests. Kalshi’s API rejects requests
that carry a non-Kalshi Origin, including extension origins, so Kalshi calls
need Node, your server, or a proxy.
Search both venues
Section titled “Search both venues”mostlyright.discover() remains offline by default. Opt in to a live market
search explicitly:
import mostlyright as mr
matches = mr.discover( "highest temperature nyc", kind="market", live=True,)kind="market" without live=True makes no network request and returns an
empty, correctly shaped frame with a message that names the required opt-in.
The TypeScript settle() function requires a caller-supplied observation loader. It remains documented in the API reference, but it is not shown as a quickstart until the package provides a direct public-data path comparable to Python.
See also
Section titled “See also”- Market data: listings, candles, fills, and order books on both venues
- Daily windows: local-standard-time settlement days
- Stations: venue and station resolution
- API overview