Skip to main content
The Simple Kalshi Bot uses a genetic algorithm to evolve profitable trading strategies over time. Instead of manually tuning parameters, the system automatically discovers optimal trading behaviors through simulated evolution.

How It Works

The genetic algorithm follows nature’s evolutionary principles:
1

Initialize Population

Create a population of 100 random trading bots, each with unique genetic parameters.
2

Evaluate Fitness

Let all bots trade live on Kalshi markets for 24 hours using paper trading.
3

Selection

Rank bots by ROI (Return on Investment). The best performers survive.
4

Reproduction

Create the next generation by combining genes from successful parents (crossover) and introducing random mutations.
5

Repeat

Run the new generation and continue evolving indefinitely.

Key Features

Automated Strategy Discovery

No manual parameter tuning required. The algorithm explores the strategy space automatically, discovering profitable combinations of:
  • Market selection criteria (volume, time to expiry, categories)
  • Entry signals (price levels, momentum, mean reversion, value, contrarian)
  • Position sizing (bankroll fraction, max concurrent positions)
  • Risk management (daily loss limits, price bounds)

Paper Trading Engine

All evolution happens using simulated trades against real Kalshi market data:
  • No real money at risk during evolution
  • Fills are simulated using actual bid/ask prices
  • Settlements use real market outcomes from the Kalshi API
  • Multiple generations can run in parallel for faster evolution

Continuous Evolution

The system runs indefinitely, continuously improving:
  • Each generation trades for 24 hours
  • Top performers pass their genes to the next generation
  • Mutations introduce new variations to explore
  • Immigration adds random diversity to prevent stagnation

Architecture Overview

┌─────────────────────────────────────────────────────────┐
│                   Evolution Loop                        │
│  ┌──────────────────────────────────────────────────┐   │
│  │  Generation N (24 hours)                         │   │
│  │                                                  │   │
│  │  ┌────────┐  ┌────────┐  ┌────────┐            │   │
│  │  │ Bot 1  │  │ Bot 2  │  │ Bot 100│  ...       │   │
│  │  │Genome A│  │Genome B│  │Genome Z│            │   │
│  │  └────┬───┘  └────┬───┘  └────┬───┘            │   │
│  │       │           │           │                 │   │
│  │       └───────────┴───────────┘                 │   │
│  │                   │                             │   │
│  │        ┌──────────▼──────────┐                  │   │
│  │        │  Market Data Feed   │                  │   │
│  │        │  (Shared Real-Time  │                  │   │
│  │        │   Kalshi Markets)   │                  │   │
│  │        └──────────┬──────────┘                  │   │
│  │                   │                             │   │
│  │        ┌──────────▼──────────┐                  │   │
│  │        │ Paper Trading Engine│                  │   │
│  │        │  (Simulated Fills)  │                  │   │
│  │        └──────────┬──────────┘                  │   │
│  │                   │                             │   │
│  │        ┌──────────▼──────────┐                  │   │
│  │        │   Fitness = ROI%    │                  │   │
│  │        └──────────┬──────────┘                  │   │
│  └───────────────────┼──────────────────────────────┘   │
│                      │                                  │
│         ┌────────────▼────────────┐                     │
│         │  Evolution Operators    │                     │
│         │  • Elite Selection      │                     │
│         │  • Tournament Selection │                     │
│         │  • Crossover            │                     │
│         │  • Mutation             │                     │
│         │  • Immigration          │                     │
│         └────────────┬────────────┘                     │
│                      │                                  │
│                      ▼                                  │
│              Generation N+1                             │
└─────────────────────────────────────────────────────────┘

Performance Metrics

Evolution progress is tracked using:
  • Fitness (ROI%): Primary metric - realized profit/loss percentage
  • Win Rate: Percentage of settled trades that were profitable
  • Trade Activity: Number of trades executed per generation
  • Signal Distribution: Which trading strategies are most successful
Bots must execute at least 5 settled trades to receive positive fitness scores. This prevents inactive bots from surviving.

Data Persistence

The system automatically saves:
  • Generation State: All genomes, fitness scores, and statistics
  • Hall of Fame: Top 20 performers across all generations
  • Checkpoints: Mid-generation snapshots for crash recovery
  • Evolution Logs: Detailed logs of every generation
All data is stored in data/evolution/ and can be analyzed offline.

Next Steps

Architecture

Deep dive into system components and data flow

Genome Structure

Understanding the 22 genes that define trading strategies

Quick Start

Run your first evolution in minutes

Monitoring

Track evolution progress in real-time

Build docs developers (and LLMs) love