Skip to content

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.

Terminal window
pip install mostlyrightmd-markets
pnpm add @mostlyrightmd/markets

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_typeYES when
greatervalue > floor_strike
greater_or_equalvalue >= floor_strike
lessvalue < cap_strike
less_or_equalvalue <= cap_strike
betweenfloor_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",
)

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 DeferredMarketError rather than resolving to a knowingly wrong station.
  • settling before a trustworthy record exists raises TooEarlyToSettleError.

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.

ErrorWhen
KalshiTickerErrorA ticker cannot be parsed or is outside the supported settlement universe
PolymarketStrikeErrorAn above, below, or between strike cannot be parsed
PolymarketEventErrorAn event cannot be validated or fetched
PolymarketSettlementErrorA trustworthy settlement value cannot be established
TooEarlyToSettleErrorSettlement is requested before the record exists
DeferredMarketErrorThe event is on a guarded unsupported path
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.

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.