Skip to content

Kalshi

Kalshi prediction markets — markets, order books, candlesticks, trades and events

Connector software
Free and open source
Service credentials
Optional
Use with an agent

Install the Orchard skill in your project to help your agent find connectors, configure them, and verify SQL results.

npx skills add Query-farm/vgi-skills --skill orchard

Copy this request into your coding agent to get started.

Use https://query.farm/products/orchard/connectors/kalshi/index.md to help me query Kalshi with DuckDB or Haybarn 2.0.1 and VGI protocol 3.4. Ask only for missing details about the result I need or whether I want local execution, self-hosting or Query Farm hosting. Check the connector's actual hosting availability, credentials and input requirements. Read one format of each needed reference and the exact object declarations before writing SQL. Use a released connector, and distinguish a saved example result from anything you actually execute. If you cannot run the query, tell me what remains to verify.

Compare active Bitcoin prediction markets

Example output · captured
Connector release
v1.5.1
Engine
2.0.1
VGI protocol
3.4.0
SELECT ticker, title, yes_bid_dollars, yes_ask_dollars, volume_24h_fp
FROM kalshi.main.markets('KXBTCD')
WHERE status = 'active'
ORDER BY volume_24h_fp DESC
Result · first 5 rows
ticker title yes_bid_dollars yes_ask_dollars volume_24h_fp
KXBTCD-26DEC0117-T57999.99 Bitcoin price on Dec 1, 2026? 0.94 0.95 51,336.78
KXBTCD-26DEC0117-T58999.99 Bitcoin price on Dec 1, 2026? 0.83 0.84 45,391.41
KXBTCD-26DEC0117-T61999.99 Bitcoin price on Dec 1, 2026? 0.1 0.11 40,964.99
KXBTCD-26DEC0417-T54999.99 Bitcoin price on Dec 4, 2026? 0.94 0.95 38,539.47
KXBTCD-26DEC0117-T62499.99 Bitcoin price on Dec 1, 2026? 0.05 0.06 33,608.57

Quick start

Choose where to run Kalshi, then follow the steps below.

The connector runs alongside DuckDB or Haybarn. No Query Farm account is needed.

1. Install the vgi extension

Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.

setup.sql
SET allow_extension_repositories = 'allowed';

CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
    WITH PREFIX 'https://duckdb-extensions.query.farm';

INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;

2. Attach the connector

Attach with uvx

Needs uv. uvx builds the worker from its release tag on first attach and reuses the cached environment after that.

ATTACH 'kalshi' AS kalshi (
  TYPE vgi,
  LOCATION 'uvx --from git+https://github.com/Query-farm/[email protected] vgi-kalshi'
);

3. Add service credentials (optional)

Market data is public; credentials are only for your own account (positions, balance). Replace the placeholders with your service settings.

kalshi credentials

Kalshi API credentials for authenticated access. Optional for market data, which is public. Provide key_id (the API Key ID) and private_key (its RSA or Ed25519 private key, PEM). Required by the margin_* account functions.

Get these credentials →
secret.sql
CREATE SECRET kalshi (
    TYPE kalshi,
    key_id      '<key_id>',
    private_key '<PRIVATE_KEY>'  -- secret
);
Credential fields and requirements →

4. Run a query

query.sql
SELECT ticker, title, yes_bid_dollars, yes_ask_dollars, volume_24h_fp
FROM kalshi.main.markets('KXBTCD')
WHERE status = 'active'
ORDER BY volume_24h_fp DESC
More example queries →
Technical details
Verified connector release
v1.5.1
Engine
2.0.1
VGI protocol
3.4.0
Verified on
December 1, 2026
Release notes on GitHub
Pin a version for production

When running the connector yourself, keep a specific release until you’re ready to upgrade. Replace the ATTACH statement above with this one and follow the same extension and credential setup.

Attach with uvx

Needs uv. uvx builds the worker from its release tag on first attach and reuses the cached environment after that.

ATTACH 'kalshi' AS kalshi (
  TYPE vgi,
  LOCATION 'uvx --from git+https://github.com/Query-farm/[email protected] vgi-kalshi'
);

Overview

Read-only public data from Kalshi, a CFTC-regulated US prediction-market exchange whose contract prices read directly as event probabilities, covering live and archived markets. Market data needs no account or API key; the margin_* functions read your own perps account with one.

ATTACH options

auth
How to treat the optional 'kalshi' secret: 'auto' (default) signs when one is present and uses public access otherwise; 'required' fails the query when none resolves; 'off' never signs.VARCHAR

Catalog

Everything kalshi exposes once attached — read straight from the worker's released build.

kalshi 1 schema
main 3 tables · 18 functions

Kalshi public market data (no credentials) and your own perps account (margin_*)

Schema examples (10)
Examples (10)

Browse the crypto series catalog

SELECT ticker, title, frequency
FROM kalshi.main.series
WHERE category = 'Crypto'
ORDER BY ticker;

Open Bitcoin daily markets with their best quotes, busiest first

SELECT ticker, title, yes_bid_dollars, yes_ask_dollars, volume_24h_fp
FROM kalshi.main.markets('KXBTCD')
WHERE status = 'active'
ORDER BY volume_24h_fp DESC;
Result · first 5 rows
ticker title yes_bid_dollars yes_ask_dollars volume_24h_fp
KXBTCD-26DEC0117-T57999.99 Bitcoin price on Dec 1, 2026? 0.94 0.95 51,336.78
KXBTCD-26DEC0117-T58999.99 Bitcoin price on Dec 1, 2026? 0.83 0.84 45,391.41
KXBTCD-26DEC0117-T61999.99 Bitcoin price on Dec 1, 2026? 0.1 0.11 40,964.99
KXBTCD-26DEC0417-T54999.99 Bitcoin price on Dec 4, 2026? 0.94 0.95 38,539.47
KXBTCD-26DEC0117-T62499.99 Bitcoin price on Dec 1, 2026? 0.05 0.06 33,608.57

Order books for a whole series in one query, via LATERAL

SELECT m.ticker, o.side, o.price_dollars, o.count_fp
FROM kalshi.main.markets('KXBTCD') m,
     LATERAL kalshi.main.orderbook(m.ticker, cache_ttl => 30) o
WHERE m.status = 'active'
ORDER BY m.ticker, o.side, o.price_dollars;

Hourly candles for every open market in a series, driven by markets()

SELECT m.ticker, c.end_period_ts, c.price_close_dollars
FROM kalshi.main.markets('KXBTCD', status => 'open') m,
     LATERAL kalshi.main.candlesticks(m.series_ticker, m.ticker, period_interval => 60) c
ORDER BY m.ticker, c.end_period_ts;
6 more examples

The most recent trades on an actively traded open market in a series

SELECT t.created_time, t.taker_side, t.yes_price_dollars, t.count_fp
FROM (SELECT ticker FROM kalshi.main.markets('KXBTCD') WHERE status = 'active' AND volume_24h_fp > 100 LIMIT 1) m,
     LATERAL kalshi.main.trades(m.ticker, max_rows => 100) t
ORDER BY t.created_time DESC;

Open Bitcoin events by strike date

SELECT event_ticker, title, strike_date
FROM kalshi.main.events('KXBTCD', status => 'open')
ORDER BY strike_date;

Upcoming Bitcoin events with their question and resolution date, plus the implied median read off each event's strike ladder: the highest strike still priced at even odds or better to settle above

SELECT e.event_ticker, e.title, e.strike_date, count(*) AS strikes,
  max(m.floor_strike) FILTER (WHERE (m.yes_bid_dollars + m.yes_ask_dollars) / 2 >= 0.5) AS implied_median,
  sum(m.open_interest_fp) AS open_interest
FROM kalshi.main.events('KXBTCD', status => 'open') AS e
JOIN kalshi.main.markets('KXBTCD', status => 'open') AS m ON m.event_ticker = e.event_ticker
WHERE m.strike_type = 'greater'
GROUP BY e.event_ticker, e.title, e.strike_date
ORDER BY e.strike_date;

Ten recently settled Bitcoin markets that traded: what each paid next to the volume-weighted price it traded at

SELECT m.ticker, m.result, m.settlement_value_dollars,
  CAST(sum(t.yes_price_dollars * t.count_fp) / sum(t.count_fp) AS DECIMAL(18,4)) AS vwap_dollars,
  sum(t.count_fp) AS contracts
FROM (SELECT ticker, result, settlement_value_dollars FROM kalshi.main.historical_markets('KXBTCD') WHERE volume_fp > 0 LIMIT 10) AS m,
     LATERAL kalshi.main.historical_trades(m.ticker) AS t
GROUP BY m.ticker, m.result, m.settlement_value_dollars
ORDER BY m.ticker;

An actively traded open market's current quote

SELECT ticker, status, yes_bid_dollars, yes_ask_dollars
FROM kalshi.main.market((SELECT ticker FROM kalshi.main.markets('KXBTCD') WHERE status = 'active' AND volume_24h_fp > 100 LIMIT 1));

Crypto series read from the scan function behind the table

SELECT ticker, title
FROM kalshi.main.all_series()
WHERE category = 'Crypto'
ORDER BY ticker;
Tables
exchange_status 2 examples7 cols

Whether the exchange, and each venue within it, is open for trading

Columns
exchange_indexnot null BIGINT
Kalshi's numeric id for this trading venue (0 = Default, 1 = Combos, 2 = Crypto, ...); a stable identifier, not a count or an ordering.
description VARCHAR
Human label for the venue, e.g. 'Default', 'Crypto'.
exchange_active BOOLEAN
Whether this venue is up at all.
trading_active BOOLEAN
Whether orders can be placed on this venue right now.
intra_exchange_transfers_active BOOLEAN
Whether positions can be transferred within this venue.
exchange_active_overall BOOLEAN
The exchange-wide flag, repeated on every row for a filter that ignores venues.
trading_active_overall BOOLEAN
The exchange-wide trading flag, repeated on every row.
ConstraintsPRIMARY KEY (exchange_index)
Examples (2)

Is the exchange open for trading right now?

SELECT description, exchange_active, trading_active
FROM kalshi.main.exchange_status
ORDER BY exchange_index;

Which venues are halted, if any

SELECT description, trading_active
FROM kalshi.main.exchange_status
ORDER BY trading_active, exchange_index;
Link
historical_cutoff 2 examples4 cols

Where Kalshi's live endpoints stop and its historical archive begins

Columns
market_settled_ts TIMESTAMP WITH TIME ZONE
Markets that settled before this are in the archive, not in markets().
trades_created_ts TIMESTAMP WITH TIME ZONE
Trades executed before this are in the archive, not in trades().
orders_updated_ts TIMESTAMP WITH TIME ZONE
Order archive boundary. Informational here: this worker exposes no order data.
market_positions_last_updated_ts TIMESTAMP WITH TIME ZONE
Position archive boundary. Informational here: this worker exposes no positions.
Examples (2)

Where does the archive begin?

SELECT market_settled_ts, trades_created_ts
FROM kalshi.main.historical_cutoff;

Decide which functions serve a given date

SELECT DATE '2026-08-01' >= market_settled_ts AS use_live_functions
FROM kalshi.main.historical_cutoff;
Link
series 2 examples10 cols

Every series on the exchange (small, slow-changing reference data)

Columns
tickernot null VARCHAR
Unique series ticker; the key markets(), events() and candlesticks() take.
title VARCHAR
Human-readable name of the series, e.g. 'Bitcoin price'.
category VARCHAR
Kalshi's top-level category, e.g. 'Crypto', 'Politics' or 'Economics'.
frequency VARCHAR
How often new events open under this series, e.g. 'daily' or 'weekly'.
fee_type VARCHAR
Fee schedule this series trades under.
fee_multiplier BIGINT
Dimensionless multiplier applied to the base trading fee for this series (1 = the standard fee; higher values scale it up).
contract_url VARCHAR
Link to the contract specification on kalshi.com.
contract_terms_url VARCHAR
Link to the full legal terms for the contract.
tags VARCHAR[]
Kalshi's own free-form topic labels for this series.
last_updated_ts TIMESTAMP WITH TIME ZONE
When Kalshi last modified this series definition.
ConstraintsPRIMARY KEY (ticker)
Examples (2)

Browse the crypto series catalog

SELECT ticker, title, frequency
FROM kalshi.main.series
WHERE category = 'Crypto'
ORDER BY ticker;

Series with the most markets, by category

SELECT category, count(*) AS series_count
FROM kalshi.main.series
GROUP BY category
ORDER BY series_count DESC;
Link
Table functions
all_exchange_status () 2 examples

Exchange and per-venue trading status (the scan backing exchange_status)

No arguments
Returns columns
exchange_index BIGINT
Kalshi's numeric id for this trading venue (0 = Default, 1 = Combos, 2 = Crypto, ...); a stable identifier, not a count or an ordering.
description VARCHAR
Human label for the venue, e.g. 'Default', 'Crypto'.
exchange_active BOOLEAN
Whether this venue is up at all.
trading_active BOOLEAN
Whether orders can be placed on this venue right now.
intra_exchange_transfers_active BOOLEAN
Whether positions can be transferred within this venue.
exchange_active_overall BOOLEAN
The exchange-wide flag, repeated on every row for a filter that ignores venues.
trading_active_overall BOOLEAN
The exchange-wide trading flag, repeated on every row.
Examples (2)

Every venue and whether it is currently trading

SELECT description, exchange_active, trading_active
FROM kalshi.main.all_exchange_status()
ORDER BY exchange_index;

Every venue's status, newest venue ids last

SELECT exchange_index, description, exchange_active, trading_active
FROM kalshi.main.all_exchange_status()
ORDER BY exchange_index;
Link
all_historical_cutoff () 2 examples

The live/archive boundary (the scan backing historical_cutoff)

No arguments
Returns columns
market_settled_ts TIMESTAMP WITH TIME ZONE
Markets that settled before this are in the archive, not in markets().
trades_created_ts TIMESTAMP WITH TIME ZONE
Trades executed before this are in the archive, not in trades().
orders_updated_ts TIMESTAMP WITH TIME ZONE
Order archive boundary. Informational here: this worker exposes no order data.
market_positions_last_updated_ts TIMESTAMP WITH TIME ZONE
Position archive boundary. Informational here: this worker exposes no positions.
Examples (2)

Where does the archive begin?

SELECT market_settled_ts, trades_created_ts
FROM kalshi.main.all_historical_cutoff();

Is a date served by the live functions or the archive?

SELECT DATE '2026-08-01' >= market_settled_ts AS use_live_functions
FROM kalshi.main.all_historical_cutoff();
Link
all_series () 1 example

Every Kalshi series (the scan backing the series table)

No arguments
Returns columns
ticker VARCHAR
Unique series ticker; the key markets(), events() and candlesticks() take.
title VARCHAR
Human-readable name of the series, e.g. 'Bitcoin price'.
category VARCHAR
Kalshi's top-level category, e.g. 'Crypto', 'Politics' or 'Economics'.
frequency VARCHAR
How often new events open under this series, e.g. 'daily' or 'weekly'.
fee_type VARCHAR
Fee schedule this series trades under.
fee_multiplier BIGINT
Dimensionless multiplier applied to the base trading fee for this series (1 = the standard fee; higher values scale it up).
contract_url VARCHAR
Link to the contract specification on kalshi.com.
contract_terms_url VARCHAR
Link to the full legal terms for the contract.
tags VARCHAR[]
Kalshi's own free-form topic labels for this series.
last_updated_ts TIMESTAMP WITH TIME ZONE
When Kalshi last modified this series definition.
Example

Crypto series, read straight from the scan function

SELECT ticker, title, frequency
FROM kalshi.main.all_series()
WHERE category = 'Crypto'
ORDER BY ticker;
Link
candlesticks (series_ticker VARCHAR, ticker VARCHAR, end_ts := BIGINT, period_interval := BIGINT, start_ts := BIGINT) 2 examples

Kalshi OHLC candlesticks for a market (series and market ticker)

Positional arguments
series_ticker VARCHAR
Series ticker input column
ticker VARCHAR
Market ticker input column
Named arguments
end_ts := BIGINT
Window end, epoch seconds (0 = now) · default 0
period_interval := BIGINT
Candle width in minutes (1, 60, or 1440) · default 60
start_ts := BIGINT
Window start, epoch seconds (0 = 24h ago) · default 0
Returns columns
ticker VARCHAR
Market these candles cover.
end_period_ts TIMESTAMP WITH TIME ZONE
Closing instant of this candle's period; the column to order and join on.
volume_fp DECIMAL(18,2)
Contracts traded during this period.
open_interest_fp DECIMAL(18,2)
Contracts outstanding at the end of this period.
price_open_dollars DECIMAL(18,4)
First trade price in the period; NULL when the period had no trades.
price_high_dollars DECIMAL(18,4)
Highest trade price in the period; NULL when the period had no trades.
price_low_dollars DECIMAL(18,4)
Lowest trade price in the period; NULL when the period had no trades.
price_close_dollars DECIMAL(18,4)
Last trade price in the period; NULL when the period had no trades.
yes_bid_open_dollars DECIMAL(18,4)
Best YES bid at the start of the period.
yes_bid_high_dollars DECIMAL(18,4)
Highest best-YES-bid seen during the period.
yes_bid_low_dollars DECIMAL(18,4)
Lowest best-YES-bid seen during the period.
yes_bid_close_dollars DECIMAL(18,4)
Best YES bid at the end of the period.
yes_ask_open_dollars DECIMAL(18,4)
Best YES ask at the start of the period.
yes_ask_high_dollars DECIMAL(18,4)
Highest best-YES-ask seen during the period.
yes_ask_low_dollars DECIMAL(18,4)
Lowest best-YES-ask seen during the period.
yes_ask_close_dollars DECIMAL(18,4)
Best YES ask at the end of the period.
Examples (2)

Hourly closing prices for one market over the last day

SELECT c.end_period_ts, c.price_close_dollars
FROM (SELECT series_ticker, ticker FROM kalshi.main.markets('KXBTCD') WHERE status = 'active' AND volume_24h_fp > 100 AND open_time < now() - INTERVAL 3 HOUR LIMIT 1) m,
     LATERAL kalshi.main.candlesticks(m.series_ticker, m.ticker, period_interval => 60) c
ORDER BY c.end_period_ts;

Hourly candles for every open market in a series, driven by markets()

SELECT m.ticker, c.end_period_ts, c.price_close_dollars
FROM kalshi.main.markets('KXBTCD', status => 'open') m,
     LATERAL kalshi.main.candlesticks(m.series_ticker, m.ticker, period_interval => 60) c
ORDER BY m.ticker, c.end_period_ts;
Link
event (event_ticker VARCHAR, cache_ttl := BIGINT) 2 examples

One Kalshi event by ticker

Positional arguments
event_ticker VARCHAR
Event ticker input column, e.g. 'KXBTCD-26SEP0417'
Named arguments
cache_ttl := BIGINT
Seconds to cache this result (0 = off) · default 0
Returns columns
event_ticker VARCHAR
Unique event ticker; the value markets() accepts as its event_ticker filter.
series_ticker VARCHAR
Series this event belongs to.
title VARCHAR
Question the event asks, e.g. 'BTC price on Sep 4, 2026 at 5pm EDT?'.
sub_title VARCHAR
Short form of the event's resolution time.
category VARCHAR
Kalshi's top-level category, e.g. 'Crypto' or 'Politics'.
collateral_return_type VARCHAR
How collateral is returned when the event resolves.
mutually_exclusive BOOLEAN
Whether exactly one market under this event can settle YES.
strike_date TIMESTAMP WITH TIME ZONE
When the event's outcome is determined.
strike_period VARCHAR
Period label used instead of a strike date for recurring events.
available_on_brokers BOOLEAN
Whether the event is offered through Kalshi's broker partners.
last_updated_ts TIMESTAMP WITH TIME ZONE
When Kalshi last modified this event's metadata.
settlement_sources STRUCT("name" VARCHAR, "url" VARCHAR)[]
Sources Kalshi settles the event against, each a {name, url} struct.
Examples (2)

One event's resolution date by ticker

SELECT event_ticker, title, strike_date
FROM kalshi.main.event('KXBTCD-26SEP0417');

The event behind each open market in a series

SELECT DISTINCT e.event_ticker, e.strike_date
FROM kalshi.main.markets('KXBTCD', status => 'open') m,
     LATERAL kalshi.main.event(m.event_ticker, cache_ttl => 60) e
ORDER BY e.strike_date;
Link
event_metadata (event_ticker VARCHAR, cache_ttl := BIGINT) 2 examples

Settlement sources and images for a Kalshi event

Positional arguments
event_ticker VARCHAR
Event ticker input column, e.g. 'KXBTCD-26SEP0417'
Named arguments
cache_ttl := BIGINT
Seconds to cache this result (0 = off) · default 0
Returns columns
event_ticker VARCHAR
Event this metadata describes.
settlement_source_name VARCHAR
Name of a source the event settles against.
settlement_source_url VARCHAR
Link to that source.
image_url VARCHAR
Event image Kalshi displays.
featured_image_url VARCHAR
Larger featured image, when Kalshi has one.
Examples (2)

What decides one event's outcome

SELECT settlement_source_name, settlement_source_url
FROM kalshi.main.event_metadata('KXBTCD-26SEP0417');

Settlement sources across a series' open events

SELECT DISTINCT md.settlement_source_name
FROM kalshi.main.events('KXBTCD', status => 'open') e,
     LATERAL kalshi.main.event_metadata(e.event_ticker, cache_ttl => 300) md
WHERE md.settlement_source_name IS NOT NULL
ORDER BY md.settlement_source_name;
Link
events (series_ticker VARCHAR, cache_ttl := BIGINT, status := VARCHAR) 3 examples

Events under a Kalshi series (series_ticker required)

Positional arguments
series_ticker VARCHAR
Series ticker, e.g. 'KXBTCD'
Named arguments
cache_ttl := BIGINT
Seconds to cache this result (0 = off) · default 0
status := VARCHAR
Event status filter · default ""
Returns columns
event_ticker VARCHAR
Unique event ticker; the value markets() accepts as its event_ticker filter.
series_ticker VARCHAR
Series this event belongs to.
title VARCHAR
Question the event asks, e.g. 'BTC price on Sep 4, 2026 at 5pm EDT?'.
sub_title VARCHAR
Short form of the event's resolution time.
category VARCHAR
Kalshi's top-level category, e.g. 'Crypto' or 'Politics'.
collateral_return_type VARCHAR
How collateral is returned when the event resolves.
mutually_exclusive BOOLEAN
Whether exactly one market under this event can settle YES.
strike_date TIMESTAMP WITH TIME ZONE
When the event's outcome is determined.
strike_period VARCHAR
Period label used instead of a strike date for recurring events.
available_on_brokers BOOLEAN
Whether the event is offered through Kalshi's broker partners.
last_updated_ts TIMESTAMP WITH TIME ZONE
When Kalshi last modified this event's metadata.
settlement_sources STRUCT("name" VARCHAR, "url" VARCHAR)[]
Sources Kalshi settles the event against, each a {name, url} struct.
Examples (3)

Open Bitcoin events by strike date

SELECT event_ticker, title, strike_date
FROM kalshi.main.events('KXBTCD', status => 'open')
ORDER BY strike_date;

Upcoming Bitcoin events with their question and resolution date, plus the implied median read off each event's strike ladder: the highest strike still priced at even odds or better to settle above

SELECT e.event_ticker, e.title, e.strike_date, count(*) AS strikes,
  max(m.floor_strike) FILTER (WHERE (m.yes_bid_dollars + m.yes_ask_dollars) / 2 >= 0.5) AS implied_median,
  sum(m.open_interest_fp) AS open_interest
FROM kalshi.main.events('KXBTCD', status => 'open') AS e
JOIN kalshi.main.markets('KXBTCD', status => 'open') AS m ON m.event_ticker = e.event_ticker
WHERE m.strike_type = 'greater'
GROUP BY e.event_ticker, e.title, e.strike_date
ORDER BY e.strike_date;

Settlement sources for each open event, one row per source

SELECT event_ticker, unnest(settlement_sources).name AS source
FROM kalshi.main.events('KXBTCD', status => 'open')
ORDER BY event_ticker, source;
Link
historical_candlesticks (ticker VARCHAR, end_ts := BIGINT, period_interval := BIGINT, start_ts := BIGINT) 2 examples

Archived OHLC candlesticks for a settled Kalshi market

Positional arguments
ticker VARCHAR
Market ticker input column
Named arguments
end_ts := BIGINT
Window end, epoch seconds (0 = the market's close) · default 0
period_interval := BIGINT
Candle width in minutes (1, 60, or 1440) · default 60
start_ts := BIGINT
Window start, epoch seconds (0 = 30d before end) · default 0
Returns columns
ticker VARCHAR
Market these candles cover.
end_period_ts TIMESTAMP WITH TIME ZONE
Closing instant of this candle's period; the column to order and join on.
volume_fp DECIMAL(18,2)
Contracts traded during this period.
open_interest_fp DECIMAL(18,2)
Contracts outstanding at the end of this period.
price_open_dollars DECIMAL(18,4)
First trade price in the period; NULL when the period had no trades.
price_high_dollars DECIMAL(18,4)
Highest trade price in the period; NULL when the period had no trades.
price_low_dollars DECIMAL(18,4)
Lowest trade price in the period; NULL when the period had no trades.
price_close_dollars DECIMAL(18,4)
Last trade price in the period; NULL when the period had no trades.
yes_bid_open_dollars DECIMAL(18,4)
Best YES bid at the start of the period.
yes_bid_high_dollars DECIMAL(18,4)
Highest best-YES-bid seen during the period.
yes_bid_low_dollars DECIMAL(18,4)
Lowest best-YES-bid seen during the period.
yes_bid_close_dollars DECIMAL(18,4)
Best YES bid at the end of the period.
yes_ask_open_dollars DECIMAL(18,4)
Best YES ask at the start of the period.
yes_ask_high_dollars DECIMAL(18,4)
Highest best-YES-ask seen during the period.
yes_ask_low_dollars DECIMAL(18,4)
Lowest best-YES-ask seen during the period.
yes_ask_close_dollars DECIMAL(18,4)
Best YES ask at the end of the period.
Examples (2)

Hourly closing prices for the most recently settled market in a series

SELECT c.end_period_ts, c.price_close_dollars
FROM (SELECT ticker FROM kalshi.main.historical_markets('KXBTCD') LIMIT 1) m,
     LATERAL kalshi.main.historical_candlesticks(m.ticker, period_interval => 60) c
ORDER BY c.end_period_ts;

Hourly high and low for a settled market

SELECT end_period_ts, price_high_dollars, price_low_dollars
FROM kalshi.main.historical_candlesticks('KXBTCD-26JUL0119-T68299.99', period_interval => 60)
ORDER BY end_period_ts;
Link
historical_markets (series_ticker VARCHAR, event_ticker := VARCHAR) 3 examples

Archived (settled) Kalshi markets, with their settlement value

Positional arguments
series_ticker VARCHAR
Series ticker input column, e.g. 'KXBTCD'
Named arguments
event_ticker := VARCHAR
Narrow to one event · default ""
Returns columns
ticker VARCHAR
Unique market ticker; the key every other market-data function takes.
series_ticker VARCHAR
Series this market belongs to. Not in Kalshi's payload — stamped on by the function that produced the row, so this output can drive candlesticks().
event_ticker VARCHAR
Event grouping this market with the other strikes resolving on the same date.
market_type VARCHAR
Contract mechanism, e.g. 'binary' or 'scalar'.
title VARCHAR
Full question the contract settles, e.g. 'BTC price on Sep 4, 2026 at 5pm EDT?'.
subtitle VARCHAR
Secondary heading distinguishing this strike within its event.
yes_sub_title VARCHAR
Label describing what a YES holder is betting on.
no_sub_title VARCHAR
Label describing what a NO holder is betting on.
strike_type VARCHAR
How to read the strike bounds: 'greater' (floor only), 'less' (cap only), or 'between' (both). The machine-readable form of what `subtitle` says in prose.
floor_strike DECIMAL(18,4)
Lower bound of the range this contract settles YES on, exclusive. Set for 'greater' and 'between' strikes, NULL for 'less'. Units are the series' own — dollars for a price market, thousands of barrels for an inventory one.
cap_strike DECIMAL(18,4)
Upper bound of the range this contract settles YES on. Set for 'less' and 'between' strikes, NULL for 'greater'. Same units as floor_strike.
custom_strike MAP(VARCHAR, VARCHAR)
Kalshi's structured key/value bag for this contract, and the only machine-readable form of what a 'custom' strike says — those markets carry NULL floor_strike and cap_strike because the outcome is categorical, not a number line. The key carries meaning as well as the value: KXFEDDECISION splits into {'Hike': '25'} and {'Cut': '25'}, which are opposite outcomes. On an ordinary numeric strike it holds contract metadata instead — KXWTI sets front_month_contract and strike_date — so it is not exclusive with the strike columns. Read it rather than parsing yes_sub_title.
price_ranges STRUCT of 3 fields[]
The tick ladder: the price bands this market quotes in, each with its own step, in dollars. Needed to tell a one-tick spread from a wide one, because the step is not the same everywhere — a market may step by 0.001 in the tails and 0.01 in the middle, so the same 0.01 spread is one tick at 0.50 and ten at 0.02. Ordered by start; look up the band containing the price of interest.
STRUCT[] 3 fields
  • startDECIMAL(18,4)
  • endDECIMAL(18,4)
  • stepDECIMAL(18,4)
status VARCHAR
Lifecycle state: initialized, active, closed, determined, settled or finalized. Note this is NOT the vocabulary the status filter argument accepts — filter with 'open' to select markets reading 'active'.
open_time TIMESTAMP WITH TIME ZONE
When the market opened, or will open, for trading.
close_time TIMESTAMP WITH TIME ZONE
When trading closes and the outcome is locked in.
expiration_time TIMESTAMP WITH TIME ZONE
When the contract expires and settlement is final.
updated_time TIMESTAMP WITH TIME ZONE
When Kalshi last changed this market's row. The staleness signal: a market whose quotes have not moved in weeks is priced but not traded, and volume alone does not distinguish that from one that simply had a quiet day.
yes_bid_dollars DECIMAL(18,4)
Best resting bid for YES, in dollars per contract (0 to 1).
yes_ask_dollars DECIMAL(18,4)
Best resting ask for YES, in dollars per contract (0 to 1).
no_bid_dollars DECIMAL(18,4)
Best resting bid for NO, in dollars per contract (0 to 1).
no_ask_dollars DECIMAL(18,4)
Best resting ask for NO, in dollars per contract (0 to 1).
last_price_dollars DECIMAL(18,4)
Price of the most recent trade, in dollars per contract.
previous_price_dollars DECIMAL(18,4)
Trade price 24 hours ago, for a day-over-day comparison.
yes_bid_size_fp DECIMAL(18,2)
Contracts resting at the best YES bid.
yes_ask_size_fp DECIMAL(18,2)
Contracts resting at the best YES ask.
volume_fp DECIMAL(18,2)
Contracts traded over this market's whole lifetime.
volume_24h_fp DECIMAL(18,2)
Contracts traded in the last 24 hours; the liquidity signal worth filtering on.
open_interest_fp DECIMAL(18,2)
Contracts currently outstanding (open positions, not cumulative volume).
liquidity_dollars DECIMAL(18,4)
Total dollar value resting in the order book on both sides.
notional_value_dollars DECIMAL(18,4)
Dollar value one contract pays out when it settles YES.
result VARCHAR
Settled outcome ('yes' or 'no'); empty until the market settles.
expiration_value VARCHAR
What the underlying actually resolved to, in the series' own units; empty until the market settles. The column a backtest scores against, since result only says which side won. String rather than a number because it is not always one: KXWTI settles to '85.76', KXFEDDECISION to 'Fed maintains rate'.
can_close_early BOOLEAN
Whether Kalshi may close this market before its scheduled close time.
settlement_value_dollars DECIMAL(18,4)
What one contract paid at settlement, in dollars (1 for the winning side, 0 for the losing one; a scalar market can settle in between).
Examples (3)

How recent Bitcoin daily markets settled

SELECT ticker, close_time, result, settlement_value_dollars
FROM (SELECT ticker, close_time, result, settlement_value_dollars FROM kalshi.main.historical_markets('KXBTCD') LIMIT 50)
ORDER BY close_time DESC, ticker;

Ten recently settled Bitcoin markets that traded: what each paid next to the volume-weighted price it traded at

SELECT m.ticker, m.result, m.settlement_value_dollars,
  CAST(sum(t.yes_price_dollars * t.count_fp) / sum(t.count_fp) AS DECIMAL(18,4)) AS vwap_dollars,
  sum(t.count_fp) AS contracts
FROM (SELECT ticker, result, settlement_value_dollars FROM kalshi.main.historical_markets('KXBTCD') WHERE volume_fp > 0 LIMIT 10) AS m,
     LATERAL kalshi.main.historical_trades(m.ticker) AS t
GROUP BY m.ticker, m.result, m.settlement_value_dollars
ORDER BY m.ticker;

Settled markets whose last traded price disagreed with the outcome

SELECT ticker, last_price_dollars, settlement_value_dollars
FROM kalshi.main.historical_markets('KXBTCD')
WHERE abs(last_price_dollars - settlement_value_dollars) > 0.5;
Link
historical_trades (ticker VARCHAR, max_rows := BIGINT, max_ts := BIGINT, min_ts := BIGINT) 2 examples

Archived executed trades for a Kalshi market

Positional arguments
ticker VARCHAR
Market ticker input column
Named arguments
max_rows := BIGINT
Cap on trades returned per market (0 = all) · default 0
max_ts := BIGINT
Only trades at or before this epoch second · default 0
min_ts := BIGINT
Only trades at or after this epoch second · default 0
Returns columns
trade_id VARCHAR
Kalshi's unique identifier for this execution.
ticker VARCHAR
Market the trade executed on.
created_time TIMESTAMP WITH TIME ZONE
When the trade executed; the cursor to poll on with min_ts.
taker_side VARCHAR
Contract side the aggressor bought: 'yes' or 'no'.
taker_outcome_side VARCHAR
Outcome the aggressor took on, as Kalshi labels it.
taker_book_side VARCHAR
Book side the aggressor hit: 'bid' or 'ask'.
is_block_trade BOOLEAN
Whether this was a negotiated block trade rather than a book execution.
yes_price_dollars DECIMAL(18,4)
Execution price quoted from the YES side, in dollars per contract.
no_price_dollars DECIMAL(18,4)
The same execution quoted from the NO side; the two sum to 1.
count_fp DECIMAL(18,2)
Contracts exchanged in this trade.
Examples (2)

The last hundred archived trades on a settled market

SELECT created_time, taker_side, yes_price_dollars, count_fp
FROM kalshi.main.historical_trades('KXBTCD-26JUL0119-T68299.99', max_rows => 100)
ORDER BY created_time DESC;

Archived volume by taker side for one market

SELECT taker_side, sum(count_fp) AS contracts
FROM kalshi.main.historical_trades('KXBTCD-26JUL0119-T68299.99')
GROUP BY taker_side
ORDER BY taker_side;
Link
margin_balance () 2 examples

Your Kalshi perps balance per subaccount: equity, initial and maintenance margin (needs an API key)

No arguments
Returns columns
subaccount INTEGER
Subaccount number: 0 is the primary (cross) account, 1-63 numbered subaccounts; an isolated position has its own.
subaccount_type VARCHAR
How the subaccount is margined: 'cross', 'isolated', 'auto_rebalance' or 'managed_isolated'.
account_equity DECIMAL(20,6)
Equity of this subaccount in dollars: cash plus position value.
position_value DECIMAL(20,6)
Mark-to-market value of the subaccount's open positions (negative for shorts).
initial_margin DECIMAL(20,6)
Initial margin requirement in dollars.
maintenance_margin DECIMAL(20,6)
Maintenance margin requirement in dollars; equity below it is liquidated.
resting_orders_margin DECIMAL(20,6)
Margin locked by resting orders (0 unless Kalshi computed it).
available_balance DECIMAL(20,6)
Available balance (0 unless Kalshi computed it).
settled_funds DECIMAL(20,6)
Account-wide settled funds, repeated on every row; NULL for a subaccount-restricted key.
Examples (2)

Equity and maintenance margin per subaccount

SELECT subaccount, subaccount_type, account_equity, maintenance_margin
FROM kalshi.main.margin_balance();

Equity and margin headroom per subaccount

SELECT subaccount, subaccount_type, account_equity, maintenance_margin,
  account_equity - maintenance_margin AS headroom
FROM kalshi.main.margin_balance();
Link
margin_funding_history (end_date := VARCHAR, start_date := VARCHAR, subaccount := BIGINT, ticker := VARCHAR) 2 examples

Funding your Kalshi perps positions paid or received, per settlement (needs an API key)

Named arguments
end_date := VARCHAR
Inclusive UTC end date, 'YYYY-MM-DD' (default: today) · default ""
start_date := VARCHAR
Inclusive UTC start date, 'YYYY-MM-DD' (default: 30 days ago) · default ""
subaccount := BIGINT
Only this subaccount number (default -1: all) · default -1
ticker := VARCHAR
Only this perp market (default: all) · default ""
Returns columns
market_ticker VARCHAR
Perp market ticker.
funding_time TIMESTAMP WITH TIME ZONE
When the funding payment was applied.
funding_rate DOUBLE
Funding rate for the period; positive means longs paid shorts.
mark_price DECIMAL(20,6)
Mark price at funding time. Per contract, as Kalshi quotes it: divide by the contract size (e.g. 0.001 oz for KXGOLDPERP, 0.0001 BTC for KXBTCPERP) for a per-unit price.
funding_amount DECIMAL(20,6)
Dollars paid or received by you: positive = received, negative = paid.
quantity DECIMAL(18,2)
Signed position size in contracts at funding time.
subaccount INTEGER
Subaccount the payment was booked to.
subaccount_type VARCHAR
How the subaccount is margined: 'cross', 'isolated', 'auto_rebalance' or 'managed_isolated'.
Examples (2)

Gold perp funding payments, oldest first

SELECT funding_time, funding_rate, funding_amount
FROM kalshi.main.margin_funding_history(ticker => 'KXGOLDPERP')
ORDER BY funding_time;

Funding received per market over the last 30 days

SELECT market_ticker, count(*) AS settlements,
  sum(funding_amount) AS received
FROM kalshi.main.margin_funding_history()
GROUP BY market_ticker;
Link
margin_positions (subaccount := BIGINT, ticker := VARCHAR) 2 examples

Your open Kalshi perps positions: size, entry, unrealized P&L, margin, fees (needs an API key)

Named arguments
subaccount := BIGINT
Only this subaccount number (default -1: all) · default -1
ticker := VARCHAR
Only this perp market, e.g. 'KXGOLDPERP' (default: all) · default ""
Returns columns
subaccount INTEGER
Subaccount number: 0 is the primary (cross) account, 1-63 numbered subaccounts; an isolated position has its own.
subaccount_type VARCHAR
How the subaccount is margined: 'cross', 'isolated', 'auto_rebalance' or 'managed_isolated'.
market_ticker VARCHAR
Perp market ticker, e.g. 'KXGOLDPERP'.
position DECIMAL(18,2)
Signed contract count: positive = long, negative = short.
entry_price DECIMAL(20,6)
Weighted average entry price of the open position. Per contract, as Kalshi quotes it: divide by the contract size (e.g. 0.001 oz for KXGOLDPERP, 0.0001 BTC for KXBTCPERP) for a per-unit price.
unrealized_pnl DECIMAL(20,6)
Mark-to-market unrealized P&L in dollars (excludes funding).
margin_used DECIMAL(20,6)
Maintenance-margin capital used by this position; NULL when it is hedged within a portfolio.
fees DECIMAL(20,6)
Fees accumulated over the life of the current open position, in dollars.
roe DOUBLE
Return on equity, percent: unrealized_pnl / margin_used * 100.
is_portfolio BOOLEAN
True when the position is margined as part of a portfolio.
Examples (2)

Every open perps position

SELECT market_ticker, subaccount_type, position, entry_price, unrealized_pnl
FROM kalshi.main.margin_positions();

Open perps positions with per-ounce entry for gold

SELECT market_ticker, position, entry_price / 0.001 AS entry_per_oz,
  unrealized_pnl, fees
FROM kalshi.main.margin_positions(ticker => 'KXGOLDPERP');
Link
margin_risk () 2 examples

Your Kalshi perps leverage and estimated liquidation price per position (needs an API key)

No arguments
Returns columns
subaccount INTEGER
Subaccount number: 0 is the primary (cross) account, 1-63 numbered subaccounts; an isolated position has its own.
subaccount_type VARCHAR
How the subaccount is margined: 'cross', 'isolated', 'auto_rebalance' or 'managed_isolated'.
market_ticker VARCHAR
Perp market ticker.
position DECIMAL(18,2)
Signed contract count: positive = long, negative = short.
mark_price DECIMAL(20,6)
Current mark price. Per contract, as Kalshi quotes it: divide by the contract size (e.g. 0.001 oz for KXGOLDPERP, 0.0001 BTC for KXBTCPERP) for a per-unit price.
position_notional DECIMAL(20,6)
Position notional in dollars.
maintenance_margin_required DECIMAL(20,6)
Maintenance margin this position needs, in dollars.
position_leverage DOUBLE
Notional over the margin backing this position.
estimated_liquidation_price DECIMAL(20,6)
Kalshi's estimated liquidation mark. Per contract, as Kalshi quotes it: divide by the contract size (e.g. 0.001 oz for KXGOLDPERP, 0.0001 BTC for KXBTCPERP) for a per-unit price.
is_portfolio BOOLEAN
True when the position is margined as part of a portfolio.
account_leverage DOUBLE
Account-wide leverage, repeated on every row.
total_position_notional DECIMAL(20,6)
Account-wide position notional, repeated on every row.
total_maintenance_margin DECIMAL(20,6)
Account-wide maintenance margin, repeated on every row.
Examples (2)

Leverage and liquidation price per position

SELECT market_ticker, position_leverage, estimated_liquidation_price
FROM kalshi.main.margin_risk();

Distance to liquidation for each position

SELECT market_ticker, mark_price, estimated_liquidation_price,
  estimated_liquidation_price / mark_price - 1 AS move_to_liquidation
FROM kalshi.main.margin_risk();
Link
market (ticker VARCHAR, cache_ttl := BIGINT) 1 example

One Kalshi market by ticker

Positional arguments
ticker VARCHAR
Market ticker input column
Named arguments
cache_ttl := BIGINT
Seconds to cache this result (0 = off; quotes are live) · default 0
Returns columns
ticker VARCHAR
Unique market ticker; the key every other market-data function takes.
series_ticker VARCHAR
Series this market belongs to. Not in Kalshi's payload — stamped on by the function that produced the row, so this output can drive candlesticks().
event_ticker VARCHAR
Event grouping this market with the other strikes resolving on the same date.
market_type VARCHAR
Contract mechanism, e.g. 'binary' or 'scalar'.
title VARCHAR
Full question the contract settles, e.g. 'BTC price on Sep 4, 2026 at 5pm EDT?'.
subtitle VARCHAR
Secondary heading distinguishing this strike within its event.
yes_sub_title VARCHAR
Label describing what a YES holder is betting on.
no_sub_title VARCHAR
Label describing what a NO holder is betting on.
strike_type VARCHAR
How to read the strike bounds: 'greater' (floor only), 'less' (cap only), or 'between' (both). The machine-readable form of what `subtitle` says in prose.
floor_strike DECIMAL(18,4)
Lower bound of the range this contract settles YES on, exclusive. Set for 'greater' and 'between' strikes, NULL for 'less'. Units are the series' own — dollars for a price market, thousands of barrels for an inventory one.
cap_strike DECIMAL(18,4)
Upper bound of the range this contract settles YES on. Set for 'less' and 'between' strikes, NULL for 'greater'. Same units as floor_strike.
custom_strike MAP(VARCHAR, VARCHAR)
Kalshi's structured key/value bag for this contract, and the only machine-readable form of what a 'custom' strike says — those markets carry NULL floor_strike and cap_strike because the outcome is categorical, not a number line. The key carries meaning as well as the value: KXFEDDECISION splits into {'Hike': '25'} and {'Cut': '25'}, which are opposite outcomes. On an ordinary numeric strike it holds contract metadata instead — KXWTI sets front_month_contract and strike_date — so it is not exclusive with the strike columns. Read it rather than parsing yes_sub_title.
price_ranges STRUCT of 3 fields[]
The tick ladder: the price bands this market quotes in, each with its own step, in dollars. Needed to tell a one-tick spread from a wide one, because the step is not the same everywhere — a market may step by 0.001 in the tails and 0.01 in the middle, so the same 0.01 spread is one tick at 0.50 and ten at 0.02. Ordered by start; look up the band containing the price of interest.
STRUCT[] 3 fields
  • startDECIMAL(18,4)
  • endDECIMAL(18,4)
  • stepDECIMAL(18,4)
status VARCHAR
Lifecycle state: initialized, active, closed, determined, settled or finalized. Note this is NOT the vocabulary the status filter argument accepts — filter with 'open' to select markets reading 'active'.
open_time TIMESTAMP WITH TIME ZONE
When the market opened, or will open, for trading.
close_time TIMESTAMP WITH TIME ZONE
When trading closes and the outcome is locked in.
expiration_time TIMESTAMP WITH TIME ZONE
When the contract expires and settlement is final.
updated_time TIMESTAMP WITH TIME ZONE
When Kalshi last changed this market's row. The staleness signal: a market whose quotes have not moved in weeks is priced but not traded, and volume alone does not distinguish that from one that simply had a quiet day.
yes_bid_dollars DECIMAL(18,4)
Best resting bid for YES, in dollars per contract (0 to 1).
yes_ask_dollars DECIMAL(18,4)
Best resting ask for YES, in dollars per contract (0 to 1).
no_bid_dollars DECIMAL(18,4)
Best resting bid for NO, in dollars per contract (0 to 1).
no_ask_dollars DECIMAL(18,4)
Best resting ask for NO, in dollars per contract (0 to 1).
last_price_dollars DECIMAL(18,4)
Price of the most recent trade, in dollars per contract.
previous_price_dollars DECIMAL(18,4)
Trade price 24 hours ago, for a day-over-day comparison.
yes_bid_size_fp DECIMAL(18,2)
Contracts resting at the best YES bid.
yes_ask_size_fp DECIMAL(18,2)
Contracts resting at the best YES ask.
volume_fp DECIMAL(18,2)
Contracts traded over this market's whole lifetime.
volume_24h_fp DECIMAL(18,2)
Contracts traded in the last 24 hours; the liquidity signal worth filtering on.
open_interest_fp DECIMAL(18,2)
Contracts currently outstanding (open positions, not cumulative volume).
liquidity_dollars DECIMAL(18,4)
Total dollar value resting in the order book on both sides.
notional_value_dollars DECIMAL(18,4)
Dollar value one contract pays out when it settles YES.
result VARCHAR
Settled outcome ('yes' or 'no'); empty until the market settles.
expiration_value VARCHAR
What the underlying actually resolved to, in the series' own units; empty until the market settles. The column a backtest scores against, since result only says which side won. String rather than a number because it is not always one: KXWTI settles to '85.76', KXFEDDECISION to 'Fed maintains rate'.
can_close_early BOOLEAN
Whether Kalshi may close this market before its scheduled close time.
Example

Current quote for one market by ticker

SELECT ticker, status, yes_bid_dollars, yes_ask_dollars
FROM kalshi.main.market((SELECT ticker FROM kalshi.main.markets('KXBTCD') WHERE status = 'active' AND volume_24h_fp > 100 LIMIT 1));
Link
markets (series_ticker VARCHAR, event_ticker := VARCHAR, exclude_parlays := BOOLEAN, status := VARCHAR) 4 examples

Markets under a Kalshi series (series_ticker required)

Positional arguments
series_ticker VARCHAR
Series ticker, e.g. 'KXBTCD'. Empty string scans every series.
Named arguments
event_ticker := VARCHAR
Narrow to one event · default ""
exclude_parlays := BOOLEAN
Drop multivariate parlay combos (KXMVE*) · default true
status := VARCHAR
Status filter: unopened, open, closed or settled (a row reads 'active', not 'open') · default ""
Returns columns
ticker VARCHAR
Unique market ticker; the key every other market-data function takes.
series_ticker VARCHAR
Series this market belongs to. Not in Kalshi's payload — stamped on by the function that produced the row, so this output can drive candlesticks().
event_ticker VARCHAR
Event grouping this market with the other strikes resolving on the same date.
market_type VARCHAR
Contract mechanism, e.g. 'binary' or 'scalar'.
title VARCHAR
Full question the contract settles, e.g. 'BTC price on Sep 4, 2026 at 5pm EDT?'.
subtitle VARCHAR
Secondary heading distinguishing this strike within its event.
yes_sub_title VARCHAR
Label describing what a YES holder is betting on.
no_sub_title VARCHAR
Label describing what a NO holder is betting on.
strike_type VARCHAR
How to read the strike bounds: 'greater' (floor only), 'less' (cap only), or 'between' (both). The machine-readable form of what `subtitle` says in prose.
floor_strike DECIMAL(18,4)
Lower bound of the range this contract settles YES on, exclusive. Set for 'greater' and 'between' strikes, NULL for 'less'. Units are the series' own — dollars for a price market, thousands of barrels for an inventory one.
cap_strike DECIMAL(18,4)
Upper bound of the range this contract settles YES on. Set for 'less' and 'between' strikes, NULL for 'greater'. Same units as floor_strike.
custom_strike MAP(VARCHAR, VARCHAR)
Kalshi's structured key/value bag for this contract, and the only machine-readable form of what a 'custom' strike says — those markets carry NULL floor_strike and cap_strike because the outcome is categorical, not a number line. The key carries meaning as well as the value: KXFEDDECISION splits into {'Hike': '25'} and {'Cut': '25'}, which are opposite outcomes. On an ordinary numeric strike it holds contract metadata instead — KXWTI sets front_month_contract and strike_date — so it is not exclusive with the strike columns. Read it rather than parsing yes_sub_title.
price_ranges STRUCT of 3 fields[]
The tick ladder: the price bands this market quotes in, each with its own step, in dollars. Needed to tell a one-tick spread from a wide one, because the step is not the same everywhere — a market may step by 0.001 in the tails and 0.01 in the middle, so the same 0.01 spread is one tick at 0.50 and ten at 0.02. Ordered by start; look up the band containing the price of interest.
STRUCT[] 3 fields
  • startDECIMAL(18,4)
  • endDECIMAL(18,4)
  • stepDECIMAL(18,4)
status VARCHAR
Lifecycle state: initialized, active, closed, determined, settled or finalized. Note this is NOT the vocabulary the status filter argument accepts — filter with 'open' to select markets reading 'active'.
open_time TIMESTAMP WITH TIME ZONE
When the market opened, or will open, for trading.
close_time TIMESTAMP WITH TIME ZONE
When trading closes and the outcome is locked in.
expiration_time TIMESTAMP WITH TIME ZONE
When the contract expires and settlement is final.
updated_time TIMESTAMP WITH TIME ZONE
When Kalshi last changed this market's row. The staleness signal: a market whose quotes have not moved in weeks is priced but not traded, and volume alone does not distinguish that from one that simply had a quiet day.
yes_bid_dollars DECIMAL(18,4)
Best resting bid for YES, in dollars per contract (0 to 1).
yes_ask_dollars DECIMAL(18,4)
Best resting ask for YES, in dollars per contract (0 to 1).
no_bid_dollars DECIMAL(18,4)
Best resting bid for NO, in dollars per contract (0 to 1).
no_ask_dollars DECIMAL(18,4)
Best resting ask for NO, in dollars per contract (0 to 1).
last_price_dollars DECIMAL(18,4)
Price of the most recent trade, in dollars per contract.
previous_price_dollars DECIMAL(18,4)
Trade price 24 hours ago, for a day-over-day comparison.
yes_bid_size_fp DECIMAL(18,2)
Contracts resting at the best YES bid.
yes_ask_size_fp DECIMAL(18,2)
Contracts resting at the best YES ask.
volume_fp DECIMAL(18,2)
Contracts traded over this market's whole lifetime.
volume_24h_fp DECIMAL(18,2)
Contracts traded in the last 24 hours; the liquidity signal worth filtering on.
open_interest_fp DECIMAL(18,2)
Contracts currently outstanding (open positions, not cumulative volume).
liquidity_dollars DECIMAL(18,4)
Total dollar value resting in the order book on both sides.
notional_value_dollars DECIMAL(18,4)
Dollar value one contract pays out when it settles YES.
result VARCHAR
Settled outcome ('yes' or 'no'); empty until the market settles.
expiration_value VARCHAR
What the underlying actually resolved to, in the series' own units; empty until the market settles. The column a backtest scores against, since result only says which side won. String rather than a number because it is not always one: KXWTI settles to '85.76', KXFEDDECISION to 'Fed maintains rate'.
can_close_early BOOLEAN
Whether Kalshi may close this market before its scheduled close time.
Examples (4)

Open Bitcoin daily markets with their best bid, busiest first

SELECT ticker, title, yes_bid_dollars, volume_24h_fp
FROM kalshi.main.markets('KXBTCD')
WHERE status = 'active'
ORDER BY volume_24h_fp DESC;

Ask Kalshi for only the open markets instead of filtering after the fact

SELECT ticker, status
FROM kalshi.main.markets('KXBTCD', status => 'open')
ORDER BY ticker;

The open Bitcoin daily markets carrying the most open interest

SELECT ticker, floor_strike, open_interest_fp
FROM kalshi.main.markets('KXBTCD', status => 'open')
ORDER BY open_interest_fp DESC, ticker
LIMIT 10;
1 more example

The implied probability curve for a price ladder, in strike order

SELECT floor_strike,
  (yes_bid_dollars + yes_ask_dollars) / 2 AS implied_probability
FROM kalshi.main.markets('KXWTI', status => 'open')
WHERE strike_type = 'greater' AND floor_strike IS NOT NULL
ORDER BY floor_strike;
Link
orderbook (ticker VARCHAR, cache_ttl := BIGINT, depth := BIGINT) 2 examples

Kalshi order book flattened to one row per side and price level

Positional arguments
ticker VARCHAR
Market ticker input column
Named arguments
cache_ttl := BIGINT
Seconds to cache this book (0 = off; books are live) · default 0
depth := BIGINT
Max price levels per side (0 = all) · default 0
Returns columns
ticker VARCHAR
Market this price level belongs to.
side VARCHAR
Which side of the contract rests here: 'yes' or 'no'.
price_dollars DECIMAL(18,4)
Price of this level, in dollars per contract (0 to 1).
count_fp DECIMAL(18,2)
Contracts resting at this price level.
Examples (2)

Full depth on both sides of one market's book

SELECT side, price_dollars, count_fp
FROM kalshi.main.orderbook((SELECT ticker FROM kalshi.main.markets('KXBTCD') WHERE status = 'active' AND volume_24h_fp > 100 LIMIT 1))
ORDER BY side, price_dollars DESC;

Books for every open market in a series, via LATERAL

SELECT m.ticker, o.side, o.price_dollars, o.count_fp
FROM kalshi.main.markets('KXBTCD') m,
     LATERAL kalshi.main.orderbook(m.ticker, cache_ttl => 30) o
WHERE m.status = 'active'
ORDER BY m.ticker, o.side, o.price_dollars;
Link
trades (ticker VARCHAR, cache_ttl := BIGINT, max_rows := BIGINT, max_ts := BIGINT, min_ts := BIGINT) 2 examples

Executed trades for a Kalshi market (the public tape)

Positional arguments
ticker VARCHAR
Market ticker input column
Named arguments
cache_ttl := BIGINT
Seconds to cache this tape (0 = off; the tape is live) · default 0
max_rows := BIGINT
Cap on trades returned per market (0 = all) · default 0
max_ts := BIGINT
Only trades at or before this epoch second · default 0
min_ts := BIGINT
Only trades at or after this epoch second · default 0
Returns columns
trade_id VARCHAR
Kalshi's unique identifier for this execution.
ticker VARCHAR
Market the trade executed on.
created_time TIMESTAMP WITH TIME ZONE
When the trade executed; the cursor to poll on with min_ts.
taker_side VARCHAR
Contract side the aggressor bought: 'yes' or 'no'.
taker_outcome_side VARCHAR
Outcome the aggressor took on, as Kalshi labels it.
taker_book_side VARCHAR
Book side the aggressor hit: 'bid' or 'ask'.
is_block_trade BOOLEAN
Whether this was a negotiated block trade rather than a book execution.
yes_price_dollars DECIMAL(18,4)
Execution price quoted from the YES side, in dollars per contract.
no_price_dollars DECIMAL(18,4)
The same execution quoted from the NO side; the two sum to 1.
count_fp DECIMAL(18,2)
Contracts exchanged in this trade.
Examples (2)

The most recent trades on an actively traded open market in a series

SELECT t.created_time, t.taker_side, t.yes_price_dollars, t.count_fp
FROM (SELECT ticker FROM kalshi.main.markets('KXBTCD') WHERE status = 'active' AND volume_24h_fp > 100 LIMIT 1) m,
     LATERAL kalshi.main.trades(m.ticker, max_rows => 100) t
ORDER BY t.created_time DESC;

Volume-weighted average price from the tape

SELECT sum(t.yes_price_dollars * t.count_fp) / sum(t.count_fp) AS vwap_dollars
FROM (SELECT ticker FROM kalshi.main.markets('KXBTCD') WHERE status = 'active' AND volume_24h_fp > 100 LIMIT 1) m,
     LATERAL kalshi.main.trades(m.ticker, max_rows => 500) t;
Link

Credentials

The secret type kalshi declares, as reported by the worker itself.

kalshi

How to get these credentials

Kalshi API credentials for authenticated access. Optional for market data, which is public. Provide key_id (the API Key ID) and private_key (its RSA or Ed25519 private key, PEM). Required by the margin_* account functions.

secret.sql
CREATE SECRET kalshi (
    TYPE kalshi,
    key_id      '<key_id>',
    private_key '<PRIVATE_KEY>'  -- secret
);
Key Type Required Description
key_id VARCHAR — API Key ID shown on Kalshi's Account > API Keys page when the key is created
private_key secret VARCHAR — RSA or Ed25519 private key (PEM) downloaded once when the API key is created

The worker doesn't mark which keys are required.

Needed by marketsmarketorderbookcandlestickstradeseventseventevent_metadataall_seriesall_exchange_statushistorical_marketshistorical_trades and 6 more functions

Create the secret in the same session, after attaching kalshi — the worker registers its secret types at ATTACH. Keys marked secret are masked in duckdb_secrets(); angle-bracket values are placeholders. Read credentials from your environment or secret store in your application and pass them through your SQL client’s parameter bindings. Keep real values out of saved SQL and history. Native DuckDB and Haybarn do not provide a SQL getenv() function.

Try these queries

series_catalog_is_populated — The series catalog returns the whole exchange in one response.

SELECT count(*) > 1000 FROM kalshi.main.series;

Uses series

markets_carry_their_series — Every market row is stamped with the series it was fetched from.

SELECT bool_and(series_ticker = 'KXBTCD')
FROM (SELECT series_ticker FROM kalshi.main.markets('KXBTCD') LIMIT 200);

Uses markets

events_belong_to_their_series — Events under a series all report that series.

SELECT bool_and(series_ticker = 'KXBTCD')
FROM (SELECT series_ticker FROM kalshi.main.events('KXBTCD') LIMIT 100);

Uses events

Ten recently settled Bitcoin markets that traded: what each paid next to the volume-weighted price it traded at

SELECT m.ticker, m.result, m.settlement_value_dollars,
  CAST(sum(t.yes_price_dollars * t.count_fp) / sum(t.count_fp) AS DECIMAL(18,4)) AS vwap_dollars,
  sum(t.count_fp) AS contracts
FROM (SELECT ticker, result, settlement_value_dollars FROM kalshi.main.historical_markets('KXBTCD') WHERE volume_fp > 0 LIMIT 10) AS m,
     LATERAL kalshi.main.historical_trades(m.ticker) AS t
GROUP BY m.ticker, m.result, m.settlement_value_dollars
ORDER BY m.ticker

Uses historical_marketshistorical_trades

An actively traded open market's current quote

SELECT ticker, status, yes_bid_dollars, yes_ask_dollars
FROM kalshi.main.market((SELECT ticker FROM kalshi.main.markets('KXBTCD') WHERE status = 'active' AND volume_24h_fp > 100 LIMIT 1))

Uses marketmarkets

Crypto series read from the scan function behind the table

SELECT ticker, title
FROM kalshi.main.all_series()
WHERE category = 'Crypto'
ORDER BY ticker

Uses all_series

4 more examples

series_and_scan_function_agree — The `series` table and the `all_series` function behind it are the same rows.

SELECT (SELECT count(*) FROM kalshi.main.series) = (SELECT count(*) FROM kalshi.main.all_series());

Uses seriesall_series

a_limit_stops_the_scan_early — A paged scan yields its first rows without walking every page — the property that keeps a LIMIT over a large series from wedging the client.

SELECT count(*)
FROM (SELECT ticker FROM kalshi.main.markets('KXBTCD') LIMIT 5);

Uses markets

prices_are_exact_decimals — Money comes back as DECIMAL, never a float.

SELECT typeof(yes_bid_dollars) FROM kalshi.main.markets('KXBTCD') LIMIT 1;

Uses markets

orderbook_sides_are_yes_or_no — A book flattens to labelled sides, or to nothing when it is empty.

SELECT bool_and(side IN ('yes', 'no')) IS NOT FALSE
FROM (SELECT o.side FROM kalshi.main.markets('KXBTCD', status => 'open') m, LATERAL kalshi.main.orderbook(m.ticker) o LIMIT 50);

Uses marketsorderbook

42 more examples in the Catalog, each listed under the table or function it uses.

Questions it can answer

Plain-English questions from the worker's agent test tasks. An AI agent with this catalog attached should answer each one with SQL.

  • Using my Kalshi API key, how much funding have my perps positions received or paid in the last 30 days, per market, and what is my account equity now?
  • Which Kalshi series cover crypto? List a few of their tickers and titles.
  • For the Kalshi series KXBTCD, which markets are currently open for trading, and what is the best yes bid on each?
  • Chart the last day of hourly closing prices for the most actively traded open market in the Kalshi series KXBTCD.
  • When does the next Kalshi KXBTCD event resolve, and what source settles it?
  • Look up the current bid and ask for one specific Kalshi market, given only its ticker: pick any open market in KXBTCD and quote it by ticker.

Kalshi is an independent open-source connector from Query.Farm. It is not affiliated with, endorsed by or sponsored by the services, projects or organisations it works with. Product names, logos and trademarks belong to their respective owners.