Skip to content

Repository files navigation

PredictBot Stack

PredictBot Stack Docker License

A cross-platform prediction market trading bot stack that operates on Polymarket, Kalshi, Manifold Markets, and PredictIt.

Quick Start β€’ Features β€’ Architecture β€’ Documentation


πŸ“‹ Overview

PredictBot Stack is a comprehensive, production-ready trading system that combines multiple trading strategies (arbitrage, market making, spike trading, and AI-driven trading) across prediction market platforms. It leverages battle-tested open-source components and integrates them through a unified architecture with:

  • 8 Trading Modules - Specialized bots for different strategies and platforms
  • AI Stack - LangGraph-based multi-agent system with 6 specialized agents
  • Admin Portal - Next.js dashboard for monitoring and control
  • Full Observability - Prometheus, Grafana, and Loki for metrics and logs
  • Event-Driven Architecture - Redis-based event bus for real-time coordination

✨ Features

Trading Capabilities

  • Multi-Platform Support: Trade simultaneously on Polymarket, Kalshi, Manifold, and PredictIt
  • Multi-Strategy Synergy: Four complementary trading strategies operating in parallel
  • AI-Driven Analysis: LLM-powered market analysis with multi-agent decision framework
  • Risk Management: Comprehensive circuit breakers, position limits, and capital allocation

Infrastructure

  • Docker Deployment: Fully containerized for easy VPS deployment
  • Profile-Based Startup: Run full stack or individual components
  • Automatic Health Checks: All services monitored with auto-restart
  • Centralized Logging: All logs aggregated in Loki, viewable in Grafana

Admin Portal

  • Real-time Dashboard: Live P&L, positions, and system status
  • Strategy Control: Enable/disable strategies, adjust parameters
  • AI Insights: View AI agent decisions and reasoning
  • Alert Management: Configure and manage notifications

πŸ—οΈ Architecture

flowchart TB
    subgraph External["External Services"]
        PM[Polymarket API]
        KL[Kalshi API]
        MF[Manifold API]
        PI[PredictIt API]
        LLM[LLM Providers<br/>OpenAI/Anthropic/Ollama]
    end

    subgraph Admin["Admin Layer"]
        AP[Admin Portal<br/>:3003]
    end

    subgraph Core["Core Services"]
        ORCH[Orchestrator<br/>:8080]
        AI_ORCH[AI Orchestrator<br/>:8081]
        EB[Event Bus<br/>Redis :6379]
    end

    subgraph Trading["Trading Modules"]
        ARB[Polymarket-Kalshi<br/>Arbitrage]
        PMM[Polymarket<br/>Market Maker]
        SPIKE[Polymarket<br/>Spike Trader]
        KAI[Kalshi AI<br/>:8000]
        MMM[Manifold<br/>Market Maker]
    end

    subgraph AI["AI Stack"]
        MCP[MCP Server<br/>:3000]
        PS[Polyseer<br/>:3001]
        OL[Ollama<br/>:11434]
    end

    subgraph Data["Data Layer"]
        PG[(PostgreSQL<br/>TimescaleDB :5432)]
        RD[(Redis<br/>:6379)]
    end

    subgraph Monitoring["Monitoring Stack"]
        PROM[Prometheus<br/>:9090]
        GRAF[Grafana<br/>:3002]
        LOKI[Loki<br/>:3100]
        PTAIL[Promtail]
    end

    %% Admin connections
    AP --> ORCH
    AP --> AI_ORCH
    AP --> PG
    AP --> RD

    %% Core connections
    ORCH --> EB
    ORCH --> PG
    AI_ORCH --> EB
    AI_ORCH --> PG
    AI_ORCH --> OL
    AI_ORCH --> LLM

    %% Trading module connections
    ARB --> PM
    ARB --> KL
    ARB --> EB
    PMM --> PM
    PMM --> EB
    SPIKE --> PM
    SPIKE --> EB
    KAI --> KL
    KAI --> EB
    MMM --> MF
    MMM --> EB

    %% AI connections
    AI_ORCH --> MCP
    AI_ORCH --> PS
    MCP --> PM
    PS --> PM

    %% Monitoring connections
    PTAIL --> LOKI
    PROM --> ORCH
    PROM --> AI_ORCH
    GRAF --> PROM
    GRAF --> LOKI
Loading

Service Ports

Service Port Description
Admin Portal 3003 Next.js dashboard
Orchestrator 8080 Central coordination API
AI Orchestrator 8081 LangGraph multi-agent API
Kalshi AI Dashboard 8000 Kalshi AI trading dashboard
MCP Server 3000 Model Context Protocol server
Polyseer 3001 Research assistant
Grafana 3002 Metrics dashboards
Prometheus 9090 Metrics collection
Loki 3100 Log aggregation
PostgreSQL 5432 TimescaleDB database
Redis 6379 Cache and event bus
Ollama 11434 Local LLM server

Trading Strategies

Strategy Description Platforms Module
Arbitrage Cross-market price discrepancy exploitation Polymarket, Kalshi polymarket-arb
Market Making Liquidity provision with spread capture Polymarket polymarket-mm
Market Making Liquidity provision with spread capture Manifold manifold-mm
Spike Trading Momentum/mean-reversion on price spikes Polymarket polymarket-spike
AI Trading LLM-powered directional trading Kalshi kalshi-ai
AI Multi-Agent 6-agent LangGraph system All platforms ai_orchestrator

AI Agents

The AI Orchestrator includes 6 specialized agents:

  1. Market Scanner Agent - Discovers and filters trading opportunities
  2. Research Agent - Deep dives into market fundamentals
  3. Sentiment Agent - Analyzes news and social sentiment
  4. Risk Agent - Evaluates position risk and portfolio impact
  5. Execution Agent - Determines optimal trade execution
  6. Supervisor Agent - Coordinates all agents and makes final decisions

πŸš€ Quick Start

Prerequisites

  • Docker and Docker Compose v2.0+
  • Git
  • 4GB+ RAM (8GB+ recommended for AI features)
  • API keys for target platforms
  • (Optional) NVIDIA GPU for local LLM with Ollama

Installation

# 1. Clone the repository
git clone https://github.com/yourusername/predictbot-stack.git
cd predictbot-stack

# 2. Initialize submodules
git submodule update --init --recursive

# 3. Run setup script
chmod +x scripts/setup.sh
./scripts/setup.sh

# 4. Configure environment
cp .env.template .env
# Edit .env with your API keys and settings

# 5. Validate configuration
python scripts/validate_config.py
python scripts/validate_secrets.py

# 6. Start in dry-run mode (recommended for first run)
./scripts/start.sh --profile full --dry-run

# 7. Access the Admin Portal
# Open http://localhost:3003 in your browser

Quick Commands

# Start all services
./scripts/start.sh --profile full

# Start minimal (trading only, no monitoring)
./scripts/start.sh --profile minimal

# Stop all services
./scripts/stop.sh

# View logs
docker-compose logs -f

# Check health
./scripts/health-check.sh

# Backup data
./scripts/backup.sh

πŸ“ Project Structure

predictbot-stack/
β”œβ”€β”€ config/                     # Configuration files
β”‚   β”œβ”€β”€ config.example.yml      # Strategy parameters template
β”‚   β”œβ”€β”€ markets.yml             # Market mappings
β”‚   β”œβ”€β”€ prometheus.yml          # Prometheus configuration
β”‚   β”œβ”€β”€ promtail-config.yml     # Log collection config
β”‚   └── grafana/                # Grafana dashboards
β”œβ”€β”€ modules/                    # Trading modules (git submodules)
β”‚   β”œβ”€β”€ polymarket_arb/         # Rust arbitrage bot
β”‚   β”œβ”€β”€ polymarket_mm/          # Python market maker
β”‚   β”œβ”€β”€ polymarket_spike/       # Python spike trader
β”‚   β”œβ”€β”€ kalshi_ai/              # Python AI trading bot
β”‚   β”œβ”€β”€ manifold_mm/            # Node.js market maker
β”‚   β”œβ”€β”€ mcp_server/             # Rust MCP server
β”‚   β”œβ”€β”€ polyseer/               # TypeScript research assistant
β”‚   β”œβ”€β”€ ai_orchestrator/        # LangGraph multi-agent system
β”‚   └── admin_portal/           # Next.js admin dashboard
β”œβ”€β”€ orchestrator/               # Central coordination
β”‚   β”œβ”€β”€ main.py                 # Entry point
β”‚   β”œβ”€β”€ risk_manager.py         # Risk management logic
β”‚   β”œβ”€β”€ position_tracker.py     # Position aggregation
β”‚   β”œβ”€β”€ capital_allocator.py    # Capital distribution
β”‚   β”œβ”€β”€ event_bus.py            # Redis event bus
β”‚   └── alert_manager.py        # Notification system
β”œβ”€β”€ database/                   # Database schemas
β”‚   └── init.sql                # PostgreSQL initialization
β”œβ”€β”€ shared/                     # Shared Python utilities
β”‚   β”œβ”€β”€ event_schemas.py        # Event type definitions
β”‚   └── logging_config.py       # Centralized logging
β”œβ”€β”€ scripts/                    # Utility scripts
β”‚   β”œβ”€β”€ setup.sh                # Initial setup
β”‚   β”œβ”€β”€ start.sh                # Start services
β”‚   β”œβ”€β”€ stop.sh                 # Stop services
β”‚   β”œβ”€β”€ backup.sh               # Backup data
β”‚   β”œβ”€β”€ health-check.sh         # Health verification
β”‚   β”œβ”€β”€ validate_config.py      # Config validator
β”‚   └── validate_secrets.py     # Secrets validator
β”œβ”€β”€ docs/                       # Documentation
β”‚   β”œβ”€β”€ quickstart.md           # Quick start guide
β”‚   β”œβ”€β”€ deployment.md           # Production deployment
β”‚   β”œβ”€β”€ configuration.md        # Configuration reference
β”‚   β”œβ”€β”€ testing.md              # Testing guide
β”‚   β”œβ”€β”€ troubleshooting.md      # Troubleshooting guide
β”‚   β”œβ”€β”€ api-reference.md        # API documentation
β”‚   β”œβ”€β”€ api-setup.md            # API key instructions
β”‚   └── security.md             # Security best practices
β”œβ”€β”€ docker-compose.yml          # Container orchestration
β”œβ”€β”€ .env.template               # Environment template
β”œβ”€β”€ .gitignore                  # Git ignore rules
└── .gitmodules                 # Submodule definitions

βš™οΈ Configuration

Environment Variables

Key environment variables (see .env.template for complete list):

# Trading Mode
DRY_RUN=1                       # 1=paper trading, 0=live trading

# Platform API Keys
POLY_PRIVATE_KEY=               # Polymarket wallet private key
KALSHI_API_KEY=                 # Kalshi API key
KALSHI_API_SECRET=              # Kalshi API secret
MANIFOLD_API_KEY=               # Manifold API key

# AI Configuration
OPENAI_API_KEY=                 # OpenAI API key
ANTHROPIC_API_KEY=              # Anthropic API key
AI_CONFIDENCE_THRESHOLD=0.6     # Minimum confidence to trade

# Risk Management
MAX_DAILY_LOSS=100              # Stop trading if exceeded
MAX_TOTAL_POSITION=1000         # Maximum total exposure

# Notifications
SLACK_WEBHOOK_URL=              # Slack alerts
DISCORD_WEBHOOK_URL=            # Discord alerts

Strategy Parameters

See config/config.example.yml for detailed strategy configuration.

πŸ›‘οΈ Risk Controls

Control Description Default
DRY_RUN Paper trading mode Enabled
MAX_DAILY_LOSS Stop trading if daily loss exceeds $100
MAX_TOTAL_POSITION Maximum total exposure $1000
ARB_MIN_PROFIT Minimum arbitrage profit threshold 2%
AI_CONFIDENCE_THRESHOLD Minimum AI confidence to trade 60%
CIRCUIT_BREAKER_THRESHOLD Failures before auto-halt 5
CIRCUIT_BREAKER_COOLDOWN Cooldown period after halt 300s

πŸ“Š Monitoring

Grafana Dashboards

Access Grafana at http://localhost:3002 (default: admin/admin)

Pre-configured dashboards:

  • System Overview - All services health and metrics
  • Trading Performance - P&L, win rate, trade volume
  • AI Insights - Agent decisions, confidence scores
  • Risk Dashboard - Position exposure, circuit breaker status

Alerts

Configure alerts via:

  • Slack - Set SLACK_WEBHOOK_URL
  • Discord - Set DISCORD_WEBHOOK_URL
  • Email - Configure SMTP settings

Alert types:

  • Trade executed
  • Circuit breaker triggered
  • Daily loss limit reached
  • Service health issues
  • AI confidence warnings

πŸ“š Documentation

Document Description
Quick Start Guide Step-by-step setup instructions
Deployment Guide Production deployment on VPS
Configuration Reference Complete configuration options
Testing Guide Testing and validation
Troubleshooting Common issues and solutions
API Reference REST API documentation
API Setup Platform API key instructions
Security Guide Security best practices

πŸ”§ Open Source Components

This project integrates the following open-source repositories:

Component Repository Language
Arbitrage Bot Polymarket-Kalshi-Arbitrage-bot Rust
Polymarket MM polymarket-market-maker-bot Python
Manifold MM market-maker TypeScript
Spike Bot Polymarket-spike-bot-v1 Python
Kalshi AI kalshi-ai-trading-bot Python
Polyseer Polyseer TypeScript
MCP Server polymarket-mcp-server Rust

⚠️ Disclaimer

USE AT YOUR OWN RISK. This software is provided for educational purposes only. Trading prediction markets involves significant financial risk.

  • Always start with DRY_RUN=1 (paper trading mode)
  • Use small position sizes when going live
  • Monitor the system closely during initial live trading
  • The authors are not responsible for any financial losses

πŸ“„ License

MIT License - See LICENSE for details.


⬆ Back to Top

Made with ❀️ for the prediction market community

About

No description, website, or topics provided.

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages