A high-performance Rust trading bot implementing advanced arbitrage strategies across Polymarket and Kalshi prediction markets.
This is not a complete, production-ready codebase. This project is continuously being improved and developed.
Use this code as a reference or starting point, not as a ready-to-deploy solution.
✅ Polymarket Trading Logic - Full implementation of Polymarket's blockchain-based trading system
✅ Cross-Platform Arbitrage - Advanced event matching and price discrepancy detection
✅ Gabagool Strategy - Single-platform hedged arbitrage on Polymarket
✅ Position Management - Comprehensive tracking and settlement system
✅ API Integration - Production-ready clients for both platforms
✅ Kalshi monitoring (TypeScript-aligned) - Config, best bid/ask, dry run, monitor logging
KALSHI_DEMO, KALSHI_BASE_PATH, PEM from file or env)GET /markets/{ticker} and /markets/{ticker}/orderbookDRY_RUN=true or KALSHI_DRY_RUN=true (no real orders)logs/monitor_{YYYY-MM-DD}_{HH}-{00|15|30|45}.logFor Rust crates and API references for Kalshi and Polymarket, see docs/RUST_APIS.md.
src/
├── main.rs # Entry point & dual-strategy orchestration
├── lib.rs # Module exports
├── config.rs # Kalshi config (demo/prod, PEM, dry run)
├── event.rs # Event data structures (MarketPrices with yes_ask/no_ask)
├── event_matcher.rs # Advanced event matching algorithms
├── arbitrage_detector.rs # Cross-platform arbitrage detection
├── gabagool_executor.rs # Gabagool trade execution
├── bot.rs # Bot orchestration & strategy execution
├── clients.rs # Polymarket & Kalshi API clients (get_market, orderbook)
├── trade_executor.rs # Cross-platform trade execution
├── position_tracker.rs # Position tracking & management
├── settlement_checker.rs # Automated settlement processing
├── monitor_logger.rs # 15m slot log files (TypeScript-aligned)
└── polymarket_blockchain.rs # Polygon blockchain integration
🚧 Work in Progress - This bot is actively being developed and improved. Features may be incomplete or change.
Note: This setup is for development/testing only. Ensure you understand the code before running with real funds.
bash
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
.env (create from .env.example):POLYGON_RPC_URL, POLYMARKET_WALLET_PRIVATE_KEYKALSHI_API_ID, KALSHI_RSA_PRIVATE_KEY (or KALSHI_PRIVATE_KEY_PATH to a PEM file)KALSHI_DEMO=true, KALSHI_BASE_PATH, DRY_RUN=true / KALSHI_DRY_RUN=true15m crypto (optional): POLYMARKET_USE_GAMMA=1, POLYMARKET_TAG_SLUG=crypto, KALSHI_SERIES_TICKER, COIN_FILTER=btc|eth|sol
Build & Run (for testing/development):
bash
cargo build --release
cargo run --release
Kalshi price monitor (optional, TypeScript-aligned):
bash
cargo run --release --bin monitor
Polls best YES/NO ask for a Kalshi market and logs to console and to logs/monitor_{YYYY-MM-DD}_{HH}-{00|15|30|45}.log.
Env: KALSHI_MONITOR_INTERVAL_MS (default 2000), KALSHI_MONITOR_TICKER (optional; else first open KXBTC15M market).
Ctrl+C to stop.
| Platform | Type | Access Method | Currency | Supported |
|---|---|---|---|---|
| Polymarket | Decentralized | Polygon (on-chain) | USDC | ✅ Full |
| Kalshi | CFTC-regulated | On-chain (Solana, data 100+ chains) + REST API | USD | ✅ Full |
Note:
trading-api.kalshi.com) for trading, not their Solana/on-chain layer.Executes simultaneous trades to lock in profit
Gabagool Strategy (Polymarket only)
Both strategies run simultaneously in parallel for maximum opportunity detection.
This project is continuously improving. Contributions, suggestions, and bug reports are welcome!
$ claude mcp add polymarket-kalshi-arbitrage-bot \
-- python -m otcore.mcp_server <graph>