<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ryan Gillett</title>
    <description>The latest articles on DEV Community by Ryan Gillett (@bearware).</description>
    <link>https://dev.to/bearware</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3893114%2F1309daae-37d6-4247-9d0e-373f1fbf0305.png</url>
      <title>DEV Community: Ryan Gillett</title>
      <link>https://dev.to/bearware</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/bearware"/>
    <language>en</language>
    <item>
      <title>I built 13 AI agents that trade Kalshi prediction markets 24/7 — here's how it works</title>
      <dc:creator>Ryan Gillett</dc:creator>
      <pubDate>Wed, 22 Apr 2026 21:57:44 +0000</pubDate>
      <link>https://dev.to/bearware/i-built-13-ai-agents-that-trade-kalshi-prediction-markets-247-heres-how-it-works-23k9</link>
      <guid>https://dev.to/bearware/i-built-13-ai-agents-that-trade-kalshi-prediction-markets-247-heres-how-it-works-23k9</guid>
      <description>&lt;p&gt;Prediction markets are fascinating. Unlike stock markets where you're guessing at company valuations, prediction markets let you bet directly on whether specific events will happen — BTC settles above $90k by 4pm, the Lakers win tonight, inflation hits 3.2% this month.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://kalshi.com" rel="noopener noreferrer"&gt;Kalshi&lt;/a&gt; is a CFTC-regulated US exchange for exactly this. And because it's regulated, you can trade programmatically via their REST API.&lt;/p&gt;

&lt;p&gt;So I built a system: &lt;strong&gt;13 autonomous agents&lt;/strong&gt; that trade Kalshi 24/7 from a desktop app. Here's how it works.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Problem with Manual Trading on Kalshi
&lt;/h2&gt;

&lt;p&gt;Most retail traders on Kalshi are:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Slow&lt;/strong&gt; — they manually browse markets, check prices, place orders&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Emotional&lt;/strong&gt; — they chase moves, overbuy winners&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Uninformed&lt;/strong&gt; — they don't have real-time feeds for the underlying asset data&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The markets are reasonably liquid (BTC crypto settlement contracts trade hundreds of contracts/day), and the odds update in near-real-time. This creates an edge for anyone with fast, systematic signals.&lt;/p&gt;

&lt;h2&gt;
  
  
  Architecture Overview
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Python backend (FastAPI) ──── 13 async agents
       │
       └── Electron shell ──── React dashboard (Vite)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two layers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Python backend&lt;/strong&gt; on &lt;code&gt;localhost:8001&lt;/code&gt; — all trading logic, API calls, WebSocket feeds&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Electron + React frontend&lt;/strong&gt; — real-time dashboard, equity curve, agent controls&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The Python backend spawns and monitors agents, collects P&amp;amp;L, and serves data via REST endpoints polled every 2 seconds.&lt;/p&gt;

&lt;h2&gt;
  
  
  The 13 Agents
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Crypto Settlement Agents (5 bots)
&lt;/h3&gt;

&lt;p&gt;These trade the BTC, SOL, XRP, DOGE, and HYPE 15-minute settlement contracts.&lt;/p&gt;

&lt;p&gt;Each contract settles YES or NO based on whether the price is above a threshold at expiry. My agents use a &lt;strong&gt;9-signal consensus model&lt;/strong&gt; — at least 6 of 9 signals must agree before placing a trade.&lt;/p&gt;

&lt;p&gt;The 9 signals:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Price vs. previous settlement (momentum)&lt;/li&gt;
&lt;li&gt;60-second price momentum&lt;/li&gt;
&lt;li&gt;VWAP deviation&lt;/li&gt;
&lt;li&gt;RSI (14-period, adapted for 15-min prediction markets)&lt;/li&gt;
&lt;li&gt;Bollinger Band position&lt;/li&gt;
&lt;li&gt;Volume-weighted direction&lt;/li&gt;
&lt;li&gt;Time-of-day pattern (crypto has intraday structure)&lt;/li&gt;
&lt;li&gt;Cross-asset correlation (BTC moves drag SOL/XRP)&lt;/li&gt;
&lt;li&gt;Order book imbalance from Kraken WebSocket&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Signal data comes from a live &lt;strong&gt;Kraken WebSocket&lt;/strong&gt; feed — sub-100ms latency on price updates.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Simplified consensus check
&lt;/span&gt;&lt;span class="n"&gt;signals&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="nf"&gt;price_momentum_signal&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
    &lt;span class="nf"&gt;sixty_sec_momentum&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
    &lt;span class="nf"&gt;vwap_deviation&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
    &lt;span class="nf"&gt;rsi_signal&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
    &lt;span class="nf"&gt;bb_position&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
    &lt;span class="nf"&gt;volume_direction&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
    &lt;span class="nf"&gt;time_of_day_bias&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
    &lt;span class="nf"&gt;cross_asset_correlation&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
    &lt;span class="nf"&gt;orderbook_imbalance&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;yes_count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;signals&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;YES&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;no_count&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;signals&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;NO&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;yes_count&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;place_order&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;YES&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;kelly_size&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;no_count&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;place_order&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;NO&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;kelly_size&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Arbitrage Bot
&lt;/h3&gt;

&lt;p&gt;Watches for &lt;strong&gt;Kalshi repricing lag&lt;/strong&gt; — the 5–30 second window after a significant price move where market makers haven't fully updated their quotes.&lt;/p&gt;

&lt;p&gt;When BTC drops 0.4% in 8 seconds on Kraken but Kalshi still shows the YES contract at 68¢ (fair value ~52¢), that's a tradeable gap. Target: ≥75% win rate.&lt;/p&gt;

&lt;h3&gt;
  
  
  Sports Bot
&lt;/h3&gt;

&lt;p&gt;Pulls live &lt;strong&gt;ESPN score feeds&lt;/strong&gt; and converts game state to win probability. If Kalshi's YES price for "Lakers win tonight" is 58¢ but the model says 72% probability, that's a 14% edge — well above the 6% threshold required to place a trade.&lt;/p&gt;

&lt;h3&gt;
  
  
  Prediction Bot
&lt;/h3&gt;

&lt;p&gt;Trades macro markets — Fed decisions, NOAA weather outcomes, political events. Uses public probability feeds (Vegas lines, polling aggregators) and news sentiment.&lt;/p&gt;

&lt;h3&gt;
  
  
  Infrastructure Agents
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Price Feed&lt;/strong&gt; — Kraken WebSocket, publishes BTC/SOL/XRP/DOGE to an in-memory event bus&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Signal Hub&lt;/strong&gt; — aggregates signals from all trading bots, deduplicates overlapping orders&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Adaptive Brain&lt;/strong&gt; — re-tunes Kelly fraction every 15 minutes based on recent win rate&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Account Manager&lt;/strong&gt; — monitors balance, open positions, enforces per-bot limits&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rapid Mode&lt;/strong&gt; — high-frequency arb for &amp;lt;30 second repricing gaps&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Risk Management
&lt;/h2&gt;

&lt;p&gt;The Adaptive Brain handles position sizing using &lt;strong&gt;fractional Kelly&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;kelly_f&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;win_rate&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;avg_win&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;loss_rate&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;avg_loss&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;avg_win&lt;/span&gt;
&lt;span class="n"&gt;safe_f&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;kelly_f&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mf"&gt;0.25&lt;/span&gt;   &lt;span class="c1"&gt;# quarter-Kelly for safety
&lt;/span&gt;&lt;span class="n"&gt;contracts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;balance&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;safe_f&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;contract_price&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;contracts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;contracts&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;MAX_CONTRACTS_PER_TRADE&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Additional guardrails:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Daily loss limit&lt;/strong&gt; — shuts all bots down if daily P&amp;amp;L drops below threshold&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dead zones&lt;/strong&gt; — no trading within 2 minutes of contract expiry (spreads widen, slippage spikes)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Drawdown guard&lt;/strong&gt; — reduces Kelly fraction when drawdown exceeds 8%&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Max contracts per trade&lt;/strong&gt; — hard cap regardless of Kelly output&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The Dashboard
&lt;/h2&gt;

&lt;p&gt;React + Vite app embedded in Electron. Real-time updates via polling the FastAPI backend.&lt;/p&gt;

&lt;p&gt;Key views:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Live tab&lt;/strong&gt; — real-time BTC/SOL/XRP/DOGE prices, active agent signals, current positions&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Analytics tab&lt;/strong&gt; — equity curve (gradient area chart via Recharts), per-bot P&amp;amp;L breakdown&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Markets tab&lt;/strong&gt; — all 200+ open Kalshi markets, filterable by category&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Live Results (Our Own Account)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;521 trades&lt;/strong&gt; executed&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;58% win rate&lt;/strong&gt; (302W / 219L)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;+$177.16 total P&amp;amp;L&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;SOL bot leading at &lt;strong&gt;+$91.61 / 61.7% win rate&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The SOL agent has been the standout — SOL's intraday volatility creates frequent strong-consensus setups.&lt;/p&gt;

&lt;h2&gt;
  
  
  Lessons Learned
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Deduplication matters more than you think.&lt;/strong&gt; When multiple bots see correlated signals on related assets, they can pile into similar positions simultaneously. The Signal Hub helps, but it still requires tuning.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Dead zones are non-negotiable.&lt;/strong&gt; Trading within 2 minutes of expiry is where bad fills happen. The spread widens dramatically as market makers hedge expiry risk.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Static thresholds are fragile.&lt;/strong&gt; The 6/9 consensus threshold works well in moderate-volatility regimes but can be too aggressive (miss trades) or too loose (bad fills) depending on conditions. Dynamic thresholds based on recent realized vol would be better.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Kelly sizing is conservative by design.&lt;/strong&gt; Quarter-Kelly feels timid until you have a 5-loss streak and realize the full-Kelly version would have wiped 40% of your balance.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try It
&lt;/h2&gt;

&lt;p&gt;The desktop app is available at &lt;strong&gt;&lt;a href="https://whop.com/bearbrief-bot/kalshi-bot-30" rel="noopener noreferrer"&gt;whop.com/bearbrief-bot/kalshi-bot-30&lt;/a&gt;&lt;/strong&gt; ($10/month). Source architecture, install scripts, and README are on &lt;a href="https://github.com/bearversion22/kalshi-bot" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Stack: Python, FastAPI, Uvicorn, Electron, React, Vite, Recharts, Kraken WS API, Kalshi REST API.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Trading prediction markets involves financial risk. Past results don't guarantee future performance.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>fintech</category>
      <category>algotrading</category>
      <category>ai</category>
    </item>
  </channel>
</rss>
