Skip to content

PetersAssistant/PolymarketBot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PolymarketBot

A conservative Polymarket trading bot that scans prediction markets for mispricings, uses Claude to evaluate trades, and places orders via the Polymarket CLOB API.

What It Does

  1. Scans active Polymarket markets via the public Gamma API
  2. Detects mispricings — probability discrepancies where YES + NO prices don't sum to ~1.0
  3. Analyzes each opportunity with Claude (optional but recommended)
  4. Confirms the mispricing with a re-check to avoid false signals
  5. Places conservative, small-position trades automatically
  6. Logs all activity and runs continuously on a configurable interval

Key Features

  • Claude-powered analysis — evaluates whether a trade makes sense before placing it
  • Conservative by default — small position sizes ($10), low daily limits ($100, 5 trades/day)
  • Confirmation checks — re-fetches prices before trading to avoid noise
  • Dry-run mode — runs with zero risk, no real orders placed
  • Daily risk limits — max trades and spend per 24 hours
  • Comprehensive logging — trade log, cycle-by-cycle output

Setup

1. Install Dependencies

cd ~/PolymarketBot
pip install -r requirements.txt

2. Configure

cp config.py.example config.py
# Edit config.py with your settings

Required environment variables (or set in config.py):

export POLYMARKET_PRIVATE_KEY="0x..."        # Your Polygon private key
export POLYMARKET_WALLET_ADDRESS="0x..."      # Your Polygon wallet address
export ANTHROPIC_API_KEY="sk-ant-..."        # Optional: for Claude analysis

⚠️ WARNING: Never commit config.py or expose your private key!

3. Check Configuration

python bot.py --check

4. Run in Dry-Run Mode (Recommended First)

python bot.py --dry-run

This will scan markets and show what it would trade without placing any orders.

5. Run in Live Mode

python bot.py --live

Or edit config.py and set LIVE_MODE = True.

6. Run One Cycle Only

python bot.py --dry-run --once

Configuration Options

Setting Default Description
DEFAULT_POSITION_SIZE $10 Base trade size
MAX_POSITION_SIZE $50 Maximum per trade
MAX_DAILY_TRADES 5 Trades per 24h
MAX_DAILY_SPEND $100 USDC spent per 24h
SCAN_INTERVAL_SECONDS 300 Seconds between scans
LIVE_MODE False Set True to place real trades
USE_CLAUDE_ANALYSIS True Use Claude to evaluate trades
CLAUDE_CONFIDENCE_THRESHOLD 0.7 Minimum Claude confidence to trade
MIN_PROBABILITY_MISPRICING 0.05 Minimum price discrepancy to act on
MIN_LIQUIDITY $100 Minimum open interest to consider
CONFIRMATION_CHECKS 2 Re-checks before placing order

How Mispricings Are Detected

The bot looks for YES + NO spread anomalies on binary markets:

  • In a properly priced binary market: YES price + NO price ≈ 1.0
  • If YES > 1 - NO + threshold, YES is expensive → bot buys NO
  • If NO > 1 - YES + threshold, NO is expensive → bot buys YES

The threshold is MIN_PROBABILITY_MISPRICING (default 5%).

Example: If YES = 65¢ and NO = 42¢, the sum is 107¢ — a 7% spread indicating a potential mispricing.

Architecture

bot.py
├── PolymarketClient    # Gamma (public) + CLOB (public) API calls
├── TradingClient       # Authenticated CLOB trading via py-clob-client
├── MispricingDetector  # Scans markets, finds mispricings
├── ClaudeAnalyzer      # Asks Claude to evaluate trades
└── PolymarketBot       # Main orchestrator: scan → analyze → trade → log

Risk Management

  • Conservative position sizing (max $50/trade)
  • Daily spend and trade limits reset every 24h
  • Claude analysis adds a human-like sanity check before each trade
  • Confirmation checks filter out momentary price noise
  • Live mode must be explicitly enabled

Limitations & Disclaimers

  • This is not financial advice. Use at your own risk.
  • Prediction markets can be inefficient, but execution, fees, and slippage can erode profits
  • The bot does NOT guarantee profitability
  • Multi-choice markets are excluded (only binary YES/NO markets are traded)
  • The bot does not automatically exit positions — it places limit orders only
  • Always start in dry-run mode and monitor closely when going live

File Structure

PolymarketBot/
├── bot.py              # Main bot code
├── config.py.example   # Configuration template
├── requirements.txt    # Python dependencies
├── README.md           # This file
├── trade_log.jsonl     # Auto-created: all trades logged here
└── daily_stats.json    # Auto-created: daily statistics

Requirements

  • Python 3.10+
  • Polygon wallet with USDC.e for trading and POL for gas
  • ANTHROPIC_API_KEY for Claude analysis (optional but recommended)

About

A conservative Polymarket trading bot that scans for mispricings and uses Claude to evaluate and place trades.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages