Kalshi AI Prediction Market Trading Bot ======================================= .. meta:: :description: Build a 24/7 Kalshi AI prediction market trading bot in Python with LumiBot built-in prediction tools to find mispriced YES/NO event contracts and cap risk. .. image:: ../docs/assets/ai-agent-workflows/kalshi-prediction-market-bot.png :alt: Research agent discovers liquid Kalshi event contracts and hands mispriced edges to the trading agent for risk-capped orders :width: 100% Prediction markets trade around the clock on macro announcements, Federal Reserve decisions, weather outcomes, financial milestones, and sports events. This 24/7 Kalshi bot uses LumiBot's built-in prediction-market tools (``prediction_discover_markets``, ``prediction_get_market``, ``prediction_quote``, and ``prediction_submit_order``) to compare live news against implied YES/NO probabilities and place small, risk-capped orders on mispriced contracts. How it works ------------ With ``self.market = "24/7"`` and ``self.sleeptime = "30M"``, two agents evaluate event markets every 30 minutes: 1. **Research agent** discovers liquid open Kalshi markets with tight spreads and clear resolution rules, compares each market's implied YES and NO prices against current news and public data available by today, and returns the top one to three mispriced contracts with exact ticker, side, estimated true probability, edge percentage, and a short thesis. 2. **Trading agent** checks live quotes and submits risk-capped Kalshi orders. It spends at most ``max_bet_usd`` per market, holds at most ``max_open_markets`` concurrent positions, only enters when the quoted ask offers at least an 8 percentage point edge over estimated probability, and takes profits or exits when the edge disappears. Want larger position caps or a slower polling interval? Adjust ``max_bet_usd``, ``max_open_markets``, or ``self.sleeptime`` in the strategy class. Run it on BotSpot ----------------- Discover community bots and run 24/7 cloud strategies on `BotSpot Marketplace `_. BotSpot hosts LumiBot strategies around the clock and connects cleanly to supported brokers and exchanges. Building or debugging your Kalshi bot with Claude, ChatGPT, Codex, or Cursor? Connect the free :doc:`BotSpot MCP ` to write strategies, run backtests, and review logs. Want hands-on training in AI trading bots across stocks, options, crypto, and prediction markets? Explore `BotSpot Courses `_ or join the `free AI Trading Challenge `_. The code -------- The full Kalshi prediction-market bot is under 80 lines of Python. LumiBot's built-in prediction tools handle contract discovery, quotes, and order submission without custom HTTP boilerplate. .. literalinclude:: ../lumibot/example_strategies/ai_kalshi_prediction_bot.py :language: python Run it yourself --------------- .. code-block:: bash pip install lumibot python -m lumibot.example_strategies.ai_kalshi_prediction_bot Add ``OPENAI_API_KEY`` and your Kalshi credentials to your ``.env`` file: * ``KALSHI_API_KEY_ID`` * ``KALSHI_PRIVATE_KEY`` (or ``KALSHI_PRIVATE_KEY_PATH``) * ``KALSHI_IS_DEMO=true`` (start in Kalshi's demo environment before trading live capital) Set ``IS_BACKTESTING=true`` with ``BACKTESTING_START`` and ``BACKTESTING_END`` to replay completed Kalshi candles through ``KalshiBacktesting``, or ``IS_BACKTESTING=false`` to run 24/7 against Kalshi demo or live markets. Good to know ------------ * Built-in ``prediction_discover_markets``, ``prediction_get_market``, ``prediction_quote``, and ``prediction_submit_order`` agent tools require a LumiBot runtime version that includes the Kalshi agent toolset. * Running every 30 minutes around the clock makes up to 48 research-and-trading cycles per day; start with ``KALSHI_IS_DEMO=true`` and monitor model token spend before scaling up. * Event contracts settle to $1.00 or $0.00 at resolution, meaning any contract held to expiration can lose 100% of the stake paid. Always keep ``max_bet_usd`` sized to risk you are willing to lose. See :doc:`agents_examples` for more AI trading bots and :doc:`strategy_run_modes` for backtest and live runners.