Alpha-testing

Building a Kalshi market-making bot

Alpha Testing

This is a separate project from the directional contract trades published on the markets page. Those positions are thesis-driven and held for edge. The bot below is an experiment in liquidity provision. It quotes both sides of the book without a directional view, and is very much still being tuned.

Why build it

I wanted to understand how Kalshi markets actually work. Who is on the other side, how prices move, and what it feels like to provide liquidity. The best way to answer that was to put something inside the market itself. The bot is imperfect and still evolving, but it has already taught me more about microstructure than watching prices from the outside.

The stack

Python and asyncio run the whole thing. aiohttp handles async REST calls to Kalshi's API, and websockets keep a persistent real-time feed of order book updates. Each request is RSA-signed, which Kalshi requires for portfolio-touching endpoints. Config and secrets live in a .env file and never touch the code itself.

Config

A single Config dataclass controls ticker, minimum spread, inventory limits, volatility thresholds, expiry, and prod vs. demo mode. Before targeting a new market, I update that block and nothing else needs to change. It sounds simple, but it saved a lot of headache when I was constantly adjusting parameters mid-session.

OrderBookState

This is the bot's live view of the market. It maintains an in-memory snapshot of bids and asks, and computes best bid, best ask, mid-price, and total depth on the fly. WebSocket snapshots and deltas feed directly into it, so the bot is always working off the freshest picture of the book. Kalshi sends prices in fixed-point dollars, so there is conversion math to get clean cent values.

InventoryManager

Market making naturally leaves you with a position. This manager tracks net exposure in real time and applies a skew to sizes. Long YES shrinks the bid and grows the ask, long NO does the opposite. There is also a hard inventory limit where the bot stops quoting the side that would worsen the position. Without this, the bot just accumulates directional risk whenever the market trends.

VolatilityGuard

A kill-switch. It keeps a rolling window of mid-price observations and, if the price moves beyond a threshold such as 5% in 60 seconds, cancels everything and sits flat for a cooldown. When a market is moving fast, you are probably the last to know why. It is better to step aside, let the dust settle, and come back when the book looks rational again. This has already saved me from a few ugly fills.

KalshiRESTClient

The REST client places orders, cancels them, checks open positions, and syncs the inventory state at startup. Every request is RSA-signed with a timestamp. On startup, the bot pulls the actual position from Kalshi before quoting, so a restart after a crash does not assume zero inventory when it might not be.

QuoteEngine

The strategy layer. Given the order book and inventory skew, it decides where to place bids and asks and how large to make them. It tries to queue-jump by a cent while keeping a minimum spread, sizes by inventory skew, and caps total size by the liquidity-incentive target. A small jitter layer adds noise to order sizes to make the footprint less obvious. The next version will start incorporating external probability estimates, but for now it is pure microstructure.

Liquidity incentives earned

Kalshi rewards posted liquidity. These payments are separate from trading P&L. Click the info icon next to a market to find out more.

MarketDatesIncentive paymentsIncentiveTrading P&LNet
KXGOVTSHUTLENGTH-26FEB07Mar 23$1.71, $3.92, $4.27$9.90$9.90
KXPPIVSCPI-27FEB01Mar 24, Mar 27$3.11, $1.00$4.11-$90.00-$85.89
KXTRUMPCHINA-26May 10$6.57$6.57-$109.00-$102.43
KXHORMUZWEEKLY-26MAY17May 17$2.12, $1.81, $13.81, $4.98, $2.93, $8.37$34.02$185.00$219.02
KXNETFLIXTOPVIEWSMOVIE-26MAY18May 17$10.89, $2.63, $11.52, $25.05, $16.72, $1.47, $16.16, $2.23$86.67-$52.00$34.67
KXNETFLIXTOPVIEWSTV-26MAY18May 17$16.71, $15.49, $4.14, $7.67, $3.24$47.25-$58.00-$10.75
KXKNESSET-27May 17$3.37, $1.03, $7.03, $12.85$24.28-$39.00-$14.72
KXLIRRSTRIKE-26May 19$8.00, $11.65, $13.95$33.60-$288.00-$254.40
KXTRUEV-26MAY19May 20$6.88, $14.91, $4.67, $7.08$33.54-$340.00-$306.46
KXVOTEHUBTRUMPUPDOWN-26MAY21May 22$18.26$18.26-$50.00-$31.74
KXSAMSUNGSTRIKE-26May 22, 24$10.02, $16.13, $14.21$40.36-$82.00-$41.64
Total$338.56-$923.00-$584.44

Trading P&L is the net result of the closed positions on each market (from the markets page), so Net = incentive + trading P&L. The KXGOVTSHUTLENGTH-26FEB07 trading P&L is excluded here because those were large directional shutdown bets, not market-making positions. The $0.46 gap to the $339.02 lifetime total is a Trump/Putin volume incentive from Nov 2025 that falls outside this CSV period.

Netflix was the big one

The Netflix movie and TV markets combined paid $133.92 in incentives, by far the largest market-making operation. The raw positions lost about $68 net, but with $134 in incentives the true net on the Netflix book was roughly +$66 profit, not a loss.

Read the P&L carefully

The same logic applies across the book. The P&L column on its own understates the true economics of market making, because it leaves out the incentives that are a core part of why the strategy works.