How it works
An experiment in whether code and an AI agent running on our own hardware can price Yes/No questions better than the market, and make money on the difference.
What it trades
Kalshi's event contracts: questions like “Will the Chiefs beat the Rams?”, “Will Denver's high be 72° to 73° tomorrow?” or “Bitcoin above $100,000 at 5 pm ET?”. A Yes contract pays $1.00 if the answer is yes and nothing otherwise, so its price is the market's probability: 46¢ means 46%. A No contract costs about 1 − the Yes price and pays if the answer is no. The bot buys either side through Alpaca's Trading API, in its own paper account that started with $10,000 of fake money.
The universe: every 10 minutes the engine reads Kalshi's whole open-market list (about 61,000 markets, leaving out multi-leg parlays) and keeps what it may trade: Sports, Politics, Elections, Economics, Weather, Entertainment, Crypto, Financials, Commodities, Science & tech, Mentions, World; at least 200 contracts traded in a day or 1,000 open; a two-sided quote. Its quotes are polled every 15 seconds for the markets that matter (held ones, open orders, the agent's watches, live model edges, the busiest). See Markets.
Two deciders
Prediction markets are close to efficient on busy questions, so an edge needs either a model that prices a question better than the crowd or news the price hasn't absorbed yet. The bot has one decider for each.
The edge core (rules, once a minute): for every market one of its three models covers, it computes a fair probability and the model's confidence (at least 60% to act), then the edge of buying each side after fees, and enters when the edge is big enough and every limit allows it. It holds up to 40 positions.
The agent handles everything news-driven: injuries and lineups, polls and rulings, the Fed and data releases, box office and launches. It runs on an open-weight model (local/qwen3.6-35b-a3b-q2) on two graphics cards in the server that runs the bot: no AI service and no per-call cost. Code wakes it when news names a market it might trade, a model finds an edge it won't take alone, or one of its own watches fires; every 3 hours it also gets a digest of busy markets no model covers. It looks things up one step at a time (its book, a market's rules, prices and order book, sportsbook lines, scoreboards, weather forecasts, the news, its past decisions) and answers with buys, each with its own probability. It is asked for calibrated probabilities: base rates first, the market's price as the starting point, and action only on evidence the price hasn't absorbed. Every step streams to the Agent page as it happens.
Rules enforced in code
- Sizing is fractional Kelly: a trade stakes 0.75 ×(probability − price) / (1 − price) of equity, capped at 15% of equity per market, 30% per event (a game's winner, spread and total together) and 60% per category, with 5% always kept in cash and at most 60 positions open. Half Kelly is aggressive on purpose; quarter Kelly is the usual cautious choice.
- Every edge is counted after costs: buying Yes costs the ask plus $0.02 a contract in fees (Kalshi's cent and Alpaca's), buying No costs 1 − the bid plus the same. The core enters from 4¢ of edge, the agent from 5¢ against its own probability; a model edge above 15¢ usually means the model missed something, so it goes to the agent instead.
- Only prices from 4¢ to 96¢, spreads up to 6¢, and markets 15 minutes to 60 days from their close. Alpaca's own quote must agree with Kalshi's within 2¢ before an order goes out.
- Alpaca's paper fills ignore the order book's depth (any size fills at the best price), so the bot never takes more than 100% of the contracts Kalshi shows at its price: paper results stay close to what live trading could do.
- Orders are limits at the touch, immediate or cancel: they fill now at that price or not at all. Every position is held until its market settles: the bot never sells, whatever the price does (no take-profits, no stops); only the owner can close a position.
- A New York day's loss of 20% stops new entries for the rest of the day. The worst a position can do is lose what it cost: there is no margin and no shorting (No is bought, not sold short).
- The agent has limits of its own: 30 new positions a day and 8 an hour, 30 open positions it opened, at most 4 new positions per wake-up, one action per market every 30 minutes. Its stake scales with its conviction, from 0.75× to 1.25× the core's.
- Circuit breakers for extreme cases: the account 20% below its peak since the agent took over (or was last resumed) pauses new entries for 24 h, when they resume by themselves (the owner can resume them sooner); a slow model or a run of invalid answers pauses the agent's entries while it lasts. Positions already held wait for their settlement either way.
Settlement
Each minute the engine checks its held markets on Kalshi. When one settles, it books the payout ($1 a contract on the winning side, nothing on the losing one), records the position's P&L and posts it. Alpaca closes the position by itself and pays the cash up to a day later, so the books use Kalshi's result at once and reconcile the cash when it arrives. Every win and loss is on Trades.
The forecast ledger
Every probability the bot acts on, from a model or the agent, is stored with the market's price at that moment. When the market resolves, both get a Brier score, and Analytics shows each source against the market and its calibration curve. A model whose last 200 resolved forecasts score worse than the market stops opening positions until it scores better again; the agent sees its own record whenever it wakes. Nightly, the engine also measures how well Kalshi's own prices predicted its settled markets: well, it turns out, which is why every edge has to come from information, not from the prices alone.
How it runs
A trading engine runs around the clock in Docker on a dedicated server. It holds the only Alpaca keys, reads Kalshi's public market data and the models' inputs (ESPN, The Odds API, Open-Meteo, the National Weather Service, Kraken, Yahoo), runs its own news engine, wakes the agent on the AI model running on the same server's graphics cards, places orders, and writes everything to MongoDB. This website reads MongoDB and opens a WebSocket to the engine for the live feed. It never trades; the owner's controls (pause, kill switch, settings, selling a position) go to the engine as signed, audited commands. Paper trading only: no real money is ever at risk.
Sister projects
- CryptoMarketBot runs the same idea on crypto, trading a Kraken paper wallet 24/7.
- StockMarketBot runs it on US stocks and defined-risk options with a $10,000 Alpaca paper account.