Skip to content

@mostlyrightmd/markets/trades

readonly close: null | number

readonly end_time_utc: null | string

Bucket-end timestamp as ISO 8601 UTC string.

readonly high: null | number

readonly low: null | number

readonly open: null | number

readonly open_interest: null | number

readonly source: "kalshi"

readonly ticker: string

The query identity, consistent with settlement rows.

readonly volume: null | number


readonly fromTime: Date

readonly interval: "1m" | "1h" | "1d"

readonly toTime: Date


readonly optional fetchFn: (input, init?) => Promise<Response>(input, init?) => Promise<Response>

Override fetch for tests. Defaults to global fetch.

MDN Reference

URL | RequestInfo

RequestInit

Promise<Response>

MDN Reference

string | URL | Request

RequestInit

Promise<Response>

readonly optional signal: AbortSignal

AbortSignal for the whole call.

readonly optional sleepBetweenMs: number

Politeness sleep between requests in ms. Default 100 (0.1 s). 0 to skip.

readonly optional timeoutMs: number

Per-attempt timeout. Default 30 000 ms.


readonly count: null | number

readonly no_price: null | number

readonly source: "kalshi"

readonly taker_side: null | "yes" | "no"

readonly trade_id: null | string

readonly ts: null | string

readonly yes_price: null | number


readonly optional maxPages: number

readonly optional since: Date

readonly optional until: Date


readonly optional depth: number


readonly price: null | number

readonly side: "yes" | "no"

readonly size: null | number

readonly source: "kalshi"


readonly optional fetchFn: (input, init?) => Promise<Response>(input, init?) => Promise<Response>

Override fetch for tests.

MDN Reference

URL | RequestInfo

RequestInit

Promise<Response>

MDN Reference

string | URL | Request

RequestInit

Promise<Response>

readonly optional signal: AbortSignal

AbortSignal for the whole call.

readonly optional sleepBetweenMs: number

Politeness sleep between requests in ms. Default 200. 0 to skip.

readonly optional timeoutMs: number

Per-attempt timeout. Default 30_000 ms.


Window and bucket arguments for polymarketHistory.

The window arguments are fromTime / toTime, the SDK’s timestamp-grain argument convention, matching KalshiCandlesArgs in this same directory and the Python _polymarket_trades.history signature. There is no alias for any other spelling.

readonly optional fidelityMinutes: number

Bucket size in minutes (default 60).

readonly fromTime: Date

Window start, inclusive.

readonly toTime: Date

Window end.


readonly price: null | number

Last-traded price in [0, 1] for the requested CLOB token.

readonly source: "polymarket.clob"

History rows live on the CLOB host.

readonly ts: null | string

readonly volume: null | number


readonly last_price: null | number

readonly liquidity: null | number

readonly market_id: null | string

readonly outcome: string

readonly source: "polymarket.gamma"

readonly volume: null | number


readonly optional end_period_ts: number

readonly optional open_interest: string | number

readonly optional open_interest_fp: string

readonly optional price: object

readonly optional close: string | number

readonly optional close_dollars: string

readonly optional high: string | number

readonly optional high_dollars: string

readonly optional low: string | number

readonly optional low_dollars: string

readonly optional open: string | number

readonly optional open_dollars: string

readonly optional volume: string | number

readonly optional volume_fp: string


readonly optional cap_strike: null | string | number

readonly optional floor_strike: null | string | number

readonly optional result: string

readonly optional strike_type: string

readonly optional ticker: string


readonly optional orderbook: object

readonly optional no: readonly KalshiOrderLevel[]

readonly optional yes: readonly KalshiOrderLevel[]

readonly optional orderbook_fp: object

readonly optional no_dollars: readonly KalshiOrderLevel[]

readonly optional yes_dollars: readonly KalshiOrderLevel[]


readonly optional count: string | number

readonly optional count_fp: string

readonly optional created_time: string | number

readonly optional no_price: string | number

readonly optional no_price_dollars: string

readonly optional taker_outcome_side: "yes" | "no"

readonly optional taker_side: "yes" | "no"

readonly optional trade_id: string

readonly optional yes_price: string | number

readonly optional yes_price_dollars: string


readonly issuer: string

readonly month: number

readonly ticker: string

readonly year: number


readonly optional now: Date


readonly optional now: Date

KalshiInterval: typeof KALSHI_INTERVALS[number]


TradesSource: "kalshi" | "polymarket.gamma" | "polymarket.clob"

Source string carried per row — load-bearing invariant for cross-frame joins.

polymarket.gamma covers /events + /events/{id} (snapshot endpoint); polymarket.clob covers /prices-history (history endpoint, on the CLOB host, which is distinct from Gamma).

const KALSHI_API_BASE: "https://api.elections.kalshi.com/trade-api/v2" = "https://api.elections.kalshi.com/trade-api/v2"

Kalshi’s public REST base. This is both a public export (do not remove) and the fallback argument resolveSourceUrl returns when the resolved catalog has no usable entry for "markets.kalshi". Resolution happens at call time inside each public fetcher (via resolveKalshiBase, once per outer call, threaded through pagination), never here at module scope.


const KALSHI_INTERVALS: readonly ["1m", "1h", "1d"]

Supported candle intervals — exact union mirrors Python INTERVALS.

fetchCandlesticks(ticker, args, opts): Promise<readonly RawKalshiCandle[]>

string

number

number

number

KalshiClientOptions = {}

Promise<readonly RawKalshiCandle[]>


fetchMarket(ticker, opts): Promise<RawKalshiMarket>

Fetch the Kalshi market object (GetMarket) for ticker.

Settlement-metadata helper — GET /markets/{ticker} on the same public, no-auth, read-only Kalshi REST API as fetchCandlesticks/fetchTrades/ fetchOrderbook. Returns the market object carrying strike_type/floor_strike/ cap_strike/result, which the caller passes to settleKalshiOutcome to settle offline. Nothing calls this for you (mirrors Python _kalshi_client.fetch_market; no auto-fetch, no persistence).

string

KalshiClientOptions = {}

Promise<RawKalshiMarket>


fetchOrderbook(ticker, args, opts): Promise<RawKalshiOrderbook>

string

number

KalshiClientOptions = {}

Promise<RawKalshiOrderbook>


fetchTrades(ticker, args, opts): Promise<readonly RawKalshiTrade[]>

string

FetchTradesArgs = {}

KalshiClientOptions = {}

Promise<readonly RawKalshiTrade[]>


invalidateTradesCache(cache, args): Promise<boolean>

Delete cached entry; returns true when a value existed before.

CacheStore

TradesCacheKey

Promise<boolean>


isCurrentUtcMonth(year, month, now): boolean

number

number

Date = ...

boolean


isFutureUtcMonth(year, month, now): boolean

number

number

Date = ...

boolean


kalshiCandles(ticker, args, opts): Promise<DataResult<KalshiCandleRow>>

string

KalshiCandlesArgs

KalshiClientOptions = {}

Promise<DataResult<KalshiCandleRow>>


kalshiFills(ticker, args, opts): Promise<DataResult<KalshiFillRow>>

string

KalshiFillsArgs = {}

KalshiClientOptions = {}

Promise<DataResult<KalshiFillRow>>


kalshiOrderbook(ticker, args, opts): Promise<DataResult<KalshiOrderbookRow>>

string

KalshiOrderbookArgs = {}

KalshiClientOptions = {}

Promise<DataResult<KalshiOrderbookRow>>


polymarketHistory(tokenId, args, opts): Promise<DataResult<PolymarketHistoryRow>>

string

CLOB token id (ERC-1155 asset id, one per outcome — YES or NO). Not a Gamma market, condition, or event id.

PolymarketHistoryArgs

PolymarketClientOptions = {}

Promise<DataResult<PolymarketHistoryRow>>


polymarketSnapshot(eventId, opts): Promise<DataResult<PolymarketSnapshotRow>>

string

PolymarketClientOptions = {}

Promise<DataResult<PolymarketSnapshotRow>>


readTradesCache<Row>(cache, args, opts): Promise<null | readonly Row[]>

Read cached trades rows. Returns null on miss / current-or-future month.

Row

CacheStore

TradesCacheKey

TradesCacheReadOpts = {}

Promise<null | readonly Row[]>


tradesCacheKey(args): string

Build the canonical key string for a (issuer, ticker, year, month).

TradesCacheKey

string


writeTradesCache<Row>(cache, args, rows, opts): Promise<boolean>

Write rows to the cache. Returns false (no-op) when:

  • the (year, month) is the current UTC month (still mutable),
  • the (year, month) is in the future, OR
  • rows is empty.

Row

CacheStore

TradesCacheKey

readonly Row[]

TradesCacheWriteOpts = {}

Promise<boolean>