@mostlyrightmd/markets/trades
Interfaces
Section titled “Interfaces”KalshiCandleRow
Section titled “KalshiCandleRow”Properties
Section titled “Properties”
readonlyclose:null|number
end_time_utc
Section titled “end_time_utc”
readonlyend_time_utc:null|string
Bucket-end timestamp as ISO 8601 UTC string.
readonlyhigh:null|number
readonlylow:null|number
readonlyopen:null|number
open_interest
Section titled “open_interest”
readonlyopen_interest:null|number
source
Section titled “source”
readonlysource:"kalshi"
ticker
Section titled “ticker”
readonlyticker:string
The query identity — a leading column (DX-H4 / CUT-06), consistent with settlement rows.
volume
Section titled “volume”
readonlyvolume:null|number
KalshiCandlesArgs
Section titled “KalshiCandlesArgs”Properties
Section titled “Properties”fromTime
Section titled “fromTime”
readonlyfromTime:Date
interval
Section titled “interval”
readonlyinterval:"1m"|"1h"|"1d"
toTime
Section titled “toTime”
readonlytoTime:Date
KalshiClientOptions
Section titled “KalshiClientOptions”Properties
Section titled “Properties”fetchFn()?
Section titled “fetchFn()?”
readonlyoptionalfetchFn: (input,init?) =>Promise<Response>(input,init?) =>Promise<Response>
Override fetch for tests. Defaults to global fetch.
Parameters
Section titled “Parameters”URL | RequestInfo
RequestInit
Returns
Section titled “Returns”Promise<Response>
Parameters
Section titled “Parameters”string | URL | Request
RequestInit
Returns
Section titled “Returns”Promise<Response>
signal?
Section titled “signal?”
readonlyoptionalsignal:AbortSignal
AbortSignal for the whole call.
sleepBetweenMs?
Section titled “sleepBetweenMs?”
readonlyoptionalsleepBetweenMs:number
Politeness sleep between requests in ms. Default 100 (0.1 s). 0 to skip.
timeoutMs?
Section titled “timeoutMs?”
readonlyoptionaltimeoutMs:number
Per-attempt timeout. Default 30 000 ms.
KalshiFillRow
Section titled “KalshiFillRow”Properties
Section titled “Properties”
readonlycount:null|number
no_price
Section titled “no_price”
readonlyno_price:null|number
source
Section titled “source”
readonlysource:"kalshi"
taker_side
Section titled “taker_side”
readonlytaker_side:null|"yes"|"no"
trade_id
Section titled “trade_id”
readonlytrade_id:null|string
readonlyts:null|string
yes_price
Section titled “yes_price”
readonlyyes_price:null|number
KalshiFillsArgs
Section titled “KalshiFillsArgs”Properties
Section titled “Properties”maxPages?
Section titled “maxPages?”
readonlyoptionalmaxPages:number
since?
Section titled “since?”
readonlyoptionalsince:Date
until?
Section titled “until?”
readonlyoptionaluntil:Date
KalshiOrderbookArgs
Section titled “KalshiOrderbookArgs”Properties
Section titled “Properties”depth?
Section titled “depth?”
readonlyoptionaldepth:number
KalshiOrderbookRow
Section titled “KalshiOrderbookRow”Properties
Section titled “Properties”
readonlyprice:null|number
readonlyside:"yes"|"no"
readonlysize:null|number
source
Section titled “source”
readonlysource:"kalshi"
PolymarketClientOptions
Section titled “PolymarketClientOptions”Properties
Section titled “Properties”fetchFn()?
Section titled “fetchFn()?”
readonlyoptionalfetchFn: (input,init?) =>Promise<Response>(input,init?) =>Promise<Response>
Override fetch for tests.
Parameters
Section titled “Parameters”URL | RequestInfo
RequestInit
Returns
Section titled “Returns”Promise<Response>
Parameters
Section titled “Parameters”string | URL | Request
RequestInit
Returns
Section titled “Returns”Promise<Response>
signal?
Section titled “signal?”
readonlyoptionalsignal:AbortSignal
AbortSignal for the whole call.
sleepBetweenMs?
Section titled “sleepBetweenMs?”
readonlyoptionalsleepBetweenMs:number
Politeness sleep between requests in ms. Default 200. 0 to skip.
timeoutMs?
Section titled “timeoutMs?”
readonlyoptionaltimeoutMs:number
Per-attempt timeout. Default 30_000 ms.
PolymarketHistoryArgs
Section titled “PolymarketHistoryArgs”Properties
Section titled “Properties”fidelityMinutes?
Section titled “fidelityMinutes?”
readonlyoptionalfidelityMinutes:number
Bucket size in minutes (default 60).
readonlyfrom:Date
readonlyto:Date
PolymarketHistoryRow
Section titled “PolymarketHistoryRow”Properties
Section titled “Properties”
readonlyprice:null|number
Last-traded price in [0, 1] for the requested CLOB token.
source
Section titled “source”
readonlysource:"polymarket.clob"
History rows live on the CLOB host (architect iter-1 CRITICAL fix).
readonlyts:null|string
volume
Section titled “volume”
readonlyvolume:null|number
PolymarketSnapshotRow
Section titled “PolymarketSnapshotRow”Properties
Section titled “Properties”last_price
Section titled “last_price”
readonlylast_price:null|number
liquidity
Section titled “liquidity”
readonlyliquidity:null|number
market_id
Section titled “market_id”
readonlymarket_id:null|string
outcome
Section titled “outcome”
readonlyoutcome:string
source
Section titled “source”
readonlysource:"polymarket.gamma"
volume
Section titled “volume”
readonlyvolume:null|number
RawKalshiCandle
Section titled “RawKalshiCandle”Properties
Section titled “Properties”end_period_ts?
Section titled “end_period_ts?”
readonlyoptionalend_period_ts:number
open_interest?
Section titled “open_interest?”
readonlyoptionalopen_interest:string|number
open_interest_fp?
Section titled “open_interest_fp?”
readonlyoptionalopen_interest_fp:string
price?
Section titled “price?”
readonlyoptionalprice:object
close?
Section titled “close?”
readonlyoptionalclose:string|number
close_dollars?
Section titled “close_dollars?”
readonlyoptionalclose_dollars:string
readonlyoptionalhigh:string|number
high_dollars?
Section titled “high_dollars?”
readonlyoptionalhigh_dollars:string
readonlyoptionallow:string|number
low_dollars?
Section titled “low_dollars?”
readonlyoptionallow_dollars:string
readonlyoptionalopen:string|number
open_dollars?
Section titled “open_dollars?”
readonlyoptionalopen_dollars:string
volume?
Section titled “volume?”
readonlyoptionalvolume:string|number
volume_fp?
Section titled “volume_fp?”
readonlyoptionalvolume_fp:string
RawKalshiOrderbook
Section titled “RawKalshiOrderbook”Properties
Section titled “Properties”orderbook?
Section titled “orderbook?”
readonlyoptionalorderbook:object
readonlyoptionalno: readonlyKalshiOrderLevel[]
readonlyoptionalyes: readonlyKalshiOrderLevel[]
orderbook_fp?
Section titled “orderbook_fp?”
readonlyoptionalorderbook_fp:object
no_dollars?
Section titled “no_dollars?”
readonlyoptionalno_dollars: readonlyKalshiOrderLevel[]
yes_dollars?
Section titled “yes_dollars?”
readonlyoptionalyes_dollars: readonlyKalshiOrderLevel[]
RawKalshiTrade
Section titled “RawKalshiTrade”Properties
Section titled “Properties”count?
Section titled “count?”
readonlyoptionalcount:string|number
count_fp?
Section titled “count_fp?”
readonlyoptionalcount_fp:string
created_time?
Section titled “created_time?”
readonlyoptionalcreated_time:string|number
no_price?
Section titled “no_price?”
readonlyoptionalno_price:string|number
no_price_dollars?
Section titled “no_price_dollars?”
readonlyoptionalno_price_dollars:string
taker_outcome_side?
Section titled “taker_outcome_side?”
readonlyoptionaltaker_outcome_side:"yes"|"no"
taker_side?
Section titled “taker_side?”
readonlyoptionaltaker_side:"yes"|"no"
trade_id?
Section titled “trade_id?”
readonlyoptionaltrade_id:string
yes_price?
Section titled “yes_price?”
readonlyoptionalyes_price:string|number
yes_price_dollars?
Section titled “yes_price_dollars?”
readonlyoptionalyes_price_dollars:string
TradesCacheKey
Section titled “TradesCacheKey”Properties
Section titled “Properties”issuer
Section titled “issuer”
readonlyissuer:string
readonlymonth:number
ticker
Section titled “ticker”
readonlyticker:string
readonlyyear:number
TradesCacheReadOpts
Section titled “TradesCacheReadOpts”Properties
Section titled “Properties”
readonlyoptionalnow:Date
TradesCacheWriteOpts
Section titled “TradesCacheWriteOpts”Properties
Section titled “Properties”
readonlyoptionalnow:Date
Type Aliases
Section titled “Type Aliases”KalshiInterval
Section titled “KalshiInterval”KalshiInterval: typeof
KALSHI_INTERVALS[number]
TradesSource
Section titled “TradesSource”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 — distinct from Gamma per architect iter-1 CRITICAL).
Variables
Section titled “Variables”KALSHI_API_BASE
Section titled “KALSHI_API_BASE”
constKALSHI_API_BASE:"https://api.elections.kalshi.com/trade-api/v2"="https://api.elections.kalshi.com/trade-api/v2"
KALSHI_INTERVALS
Section titled “KALSHI_INTERVALS”
constKALSHI_INTERVALS: readonly ["1m","1h","1d"]
Supported candle intervals — exact union mirrors Python INTERVALS.
Functions
Section titled “Functions”fetchCandlesticks()
Section titled “fetchCandlesticks()”fetchCandlesticks(
ticker,args,opts):Promise<readonlyRawKalshiCandle[]>
Parameters
Section titled “Parameters”ticker
Section titled “ticker”string
number
periodIntervalMinutes
Section titled “periodIntervalMinutes”number
startTs
Section titled “startTs”number
KalshiClientOptions = {}
Returns
Section titled “Returns”Promise<readonly RawKalshiCandle[]>
fetchOrderbook()
Section titled “fetchOrderbook()”fetchOrderbook(
ticker,args,opts):Promise<RawKalshiOrderbook>
Parameters
Section titled “Parameters”ticker
Section titled “ticker”string
depth?
Section titled “depth?”number
KalshiClientOptions = {}
Returns
Section titled “Returns”Promise<RawKalshiOrderbook>
fetchTrades()
Section titled “fetchTrades()”fetchTrades(
ticker,args,opts):Promise<readonlyRawKalshiTrade[]>
Parameters
Section titled “Parameters”ticker
Section titled “ticker”string
FetchTradesArgs = {}
KalshiClientOptions = {}
Returns
Section titled “Returns”Promise<readonly RawKalshiTrade[]>
invalidateTradesCache()
Section titled “invalidateTradesCache()”invalidateTradesCache(
cache,args):Promise<boolean>
Delete cached entry; returns true when a value existed before.
Parameters
Section titled “Parameters”CacheStore
Returns
Section titled “Returns”Promise<boolean>
isCurrentUtcMonth()
Section titled “isCurrentUtcMonth()”isCurrentUtcMonth(
year,month,now):boolean
Parameters
Section titled “Parameters”number
number
Date = ...
Returns
Section titled “Returns”boolean
isFutureUtcMonth()
Section titled “isFutureUtcMonth()”isFutureUtcMonth(
year,month,now):boolean
Parameters
Section titled “Parameters”number
number
Date = ...
Returns
Section titled “Returns”boolean
kalshiCandles()
Section titled “kalshiCandles()”kalshiCandles(
ticker,args,opts):Promise<DataResult<KalshiCandleRow>>
Parameters
Section titled “Parameters”ticker
Section titled “ticker”string
KalshiClientOptions = {}
Returns
Section titled “Returns”Promise<DataResult<KalshiCandleRow>>
kalshiFills()
Section titled “kalshiFills()”kalshiFills(
ticker,args,opts):Promise<DataResult<KalshiFillRow>>
Parameters
Section titled “Parameters”ticker
Section titled “ticker”string
KalshiFillsArgs = {}
KalshiClientOptions = {}
Returns
Section titled “Returns”Promise<DataResult<KalshiFillRow>>
kalshiOrderbook()
Section titled “kalshiOrderbook()”kalshiOrderbook(
ticker,args,opts):Promise<DataResult<KalshiOrderbookRow>>
Parameters
Section titled “Parameters”ticker
Section titled “ticker”string
KalshiOrderbookArgs = {}
KalshiClientOptions = {}
Returns
Section titled “Returns”Promise<DataResult<KalshiOrderbookRow>>
polymarketHistory()
Section titled “polymarketHistory()”polymarketHistory(
tokenId,args,opts):Promise<DataResult<PolymarketHistoryRow>>
Parameters
Section titled “Parameters”tokenId
Section titled “tokenId”string
CLOB token id (ERC-1155 asset id, one per outcome — YES or NO). NOT a Gamma market/condition/event id. Architect iter-1 CRITICAL fix.
Returns
Section titled “Returns”Promise<DataResult<PolymarketHistoryRow>>
polymarketSnapshot()
Section titled “polymarketSnapshot()”polymarketSnapshot(
eventId,opts):Promise<DataResult<PolymarketSnapshotRow>>
Parameters
Section titled “Parameters”eventId
Section titled “eventId”string
Returns
Section titled “Returns”Promise<DataResult<PolymarketSnapshotRow>>
readTradesCache()
Section titled “readTradesCache()”readTradesCache<
Row>(cache,args,opts):Promise<null| readonlyRow[]>
Read cached trades rows. Returns null on miss / current-or-future month.
Type Parameters
Section titled “Type Parameters”• Row
Parameters
Section titled “Parameters”CacheStore
TradesCacheReadOpts = {}
Returns
Section titled “Returns”Promise<null | readonly Row[]>
tradesCacheKey()
Section titled “tradesCacheKey()”tradesCacheKey(
args):string
Build the canonical key string for a (issuer, ticker, year, month).
Parameters
Section titled “Parameters”Returns
Section titled “Returns”string
writeTradesCache()
Section titled “writeTradesCache()”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.
Type Parameters
Section titled “Type Parameters”• Row
Parameters
Section titled “Parameters”CacheStore
readonly Row[]
TradesCacheWriteOpts = {}
Returns
Section titled “Returns”Promise<boolean>