Skip to main content
Glama
Polymarket Autonomous Trader

Polymarket Autonomous Trader

by vulcan-sport

Polymarket Autonomous Trader

Claude-powered autonomous trading system for Polymarket prediction markets.

Features

  • Thesis → Markets: Describe an investment thesis in natural language; Claude finds, scores, and recommends the best markets to trade

  • Autonomous Trading: Claude monitors markets continuously and executes within configurable risk limits

  • MCP Integration: All trading capabilities exposed as MCP tools in Claude Desktop / Claude Code

  • Risk Management: Configurable position limits, daily loss limits, exposure caps

  • HFT Extension Point: Abstract pricing engine interface ready for Kelly criterion, ML models, or poker-inspired strategies

  • Confirm-Before-Trade: Safe default mode — Claude proposes, you approve

Related MCP server: polymarket-mcp

Prerequisites

  • Python 3.11+

  • uv package manager

  • A Polymarket account with USDC on Polygon

  • Your wallet's private key

  • An Anthropic API key

Setup

1. Install dependencies

curl -LsSf https://astral.sh/uv/install.sh | sh
cd /path/to/Polymarket
uv sync

2. Configure secrets

cp .env.example .env
# Edit .env with your POLYMARKET_PRIVATE_KEY, POLYMARKET_WALLET_ADDRESS, and ANTHROPIC_API_KEY

3. Generate CLOB API credentials (one-time)

uv run python scripts/setup_credentials.py
# Copy the printed API_KEY, API_SECRET, API_PASSPHRASE into .env

4. Configure risk limits

Edit config.yaml to set position sizes, loss limits, and approval mode.

5. Connect to Claude Desktop

Add to ~/Library/Application Support/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "polymarket-trader": {
      "command": "uv",
      "args": [
        "--directory",
        "/Users/parthgosalia/Desktop/Polymarket",
        "run",
        "python",
        "-m",
        "polymarket_trader.mcp.server"
      ]
    }
  }
}

Restart Claude Desktop. The trading tools will appear automatically.

Usage

Search markets

"Search for markets about the 2026 US midterm elections"

Thesis-driven trading

"Analyze my thesis: AI regulation will pass in the EU before end of 2026"

Check portfolio

"Show me my current positions and P&L"

Autonomous loop

"Start monitoring markets for my thesis that crypto will have a major regulatory event in 2026"

Toggle autonomous mode

"Set approval mode to autonomous" (trades within your risk limits without asking)

Risk Limits (config.yaml)

Setting

Default

Description

approval_mode

confirm

confirm = approve each trade; autonomous = auto-execute

max_position_size_usdc

100

Max size per single position

max_total_exposure_usdc

500

Max total open exposure across all positions

daily_loss_limit_usdc

50

Halt trading if daily losses exceed this

min_edge_threshold

0.03

Min probability edge (3%) required to trade

max_kelly_fraction

0.25

Cap Kelly sizing at 25% of theoretical

HFT Extension

To plug in a custom pricing engine (e.g., ML-based or poker-inspired HFT):

  1. Subclass PricingEngine from src/polymarket_trader/pricing/base.py

  2. Implement compute_signal() and calibrate()

  3. Register the engine name in config.yaml under api.pricing_engine

See src/polymarket_trader/pricing/base.py for the full interface.

Architecture

MCP Server (Claude ↔ Tools)
    ↓
TradeExecutor (orchestration)
    ├── CLOBConnector   ← py-clob-client (orders, orderbook, auth)
    ├── GammaConnector  ← market search
    ├── DataConnector   ← positions, P&L
    ├── ClaudeAnalyst   ← thesis scoring, probability estimation
    ├── PricingEngine   ← Kelly/HFT signal generation
    └── RiskManager     ← limits, approval gates

Running Tests

uv run pytest

Available Tools

22 tools
analyze_thesisA

Analyze an investment thesis and find the best Polymarket markets to trade.

Claude will:

  1. Extract keywords from your thesis

  2. Search for relevant markets

  3. Score each market by relevance, edge, and liquidity

  4. Return ranked trade recommendations

Example thesis: "I believe Trump will sign a crypto executive order before June 2026"

Inputs: thesis (required), max_markets. Returns: result

approve_tradeA

Approve a pending trade decision and execute it immediately. Only needed in confirm mode (the default).

Inputs: decision_id (required). Returns: result

cancel_all_ordersA

Cancel all open orders across all markets.

Inputs: no named parameters. Returns: result

cancel_orderA

Cancel a specific open order.

Inputs: order_id (required). Returns: result

estimate_market_probabilityB

Ask Claude to estimate the true probability for a market's YES outcome. Optionally provide additional context to inform the estimate.

Inputs: condition_id (required), context. Returns: result

find_arbitrageB

Check if YES + NO prices sum to something other than 1.0, indicating a potential arbitrage.

Inputs: condition_id (required). Returns: result

get_balanceA

Return USDC balance available for trading.

Inputs: no named parameters. Returns: result

get_loop_statusA

Return current loop state, active thesis, pending decisions, and iteration count.

Inputs: no named parameters. Returns: result

get_market_detailsB

Get full details for a specific market including live orderbook snapshot.

Inputs: condition_id (required). Returns: result

get_open_ordersB

List all live (unfilled) orders.

Inputs: no named parameters. Returns: result

get_orderbookB

Get live orderbook (bids and asks) for a specific outcome token.

Inputs: token_id (required). Returns: result

get_pnl_summaryA

Return daily realized P&L, total unrealized P&L, and portfolio value.

Inputs: no named parameters. Returns: result

get_portfolioA

Show all current positions with unrealized P&L and current prices.

Inputs: no named parameters. Returns: result

get_risk_statusA

Return current risk limits, daily loss consumed, exposure, and limit utilization.

Inputs: no named parameters. Returns: result

place_orderA

Place a limit order on a market.

In confirm mode (default): returns a pending decision for your approval. In autonomous mode: executes immediately if within risk limits.

Args: condition_id: Market condition ID side: "YES" to buy YES shares, "NO" to buy NO shares price: Limit price (0.01 – 0.99) size_usdc: Position size in USDC order_type: "GTC" (Good Till Cancel) or "FOK" (Fill or Kill)

Inputs: side (required), price (required), size_usdc (required), condition_id (required), +1 more. Returns: result

reject_tradeB

Reject a pending trade decision without executing it.

Inputs: decision_id (required), reason. Returns: result

search_marketsB

Search Polymarket markets by keyword. Returns markets with current prices, volume, and liquidity.

Inputs: query (required), limit, active_only. Returns: result

set_approval_modeA

Toggle trading approval mode.

'confirm' = Claude proposes trades, you must approve each one (safe default) 'autonomous' = Claude executes trades within risk limits without asking

Inputs: mode (required). Returns: result

start_autonomous_loopA

Start continuous market monitoring for a given investment thesis.

Claude will scan markets every poll_interval_seconds, identify opportunities, and either propose trades (confirm mode) or execute them automatically (autonomous mode).

Inputs: thesis (required), poll_interval_seconds. Returns: result

stop_autonomous_loopB

Gracefully stop the autonomous trading loop.

Inputs: no named parameters. Returns: result

update_risk_limitsA

Update runtime risk limits without restarting the server.

Args: max_position_usdc: Max size per individual position in USDC daily_loss_limit_usdc: Halt trading if daily losses exceed this amount max_exposure_usdc: Max total open exposure across all positions min_edge: Minimum probability edge (e.g. 0.03 = 3%) required to trade

Inputs: min_edge, max_exposure_usdc, max_position_usdc, daily_loss_limit_usdc. Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.7/5.0

    Scored across 22 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose. Market exploration tools (search, details, trending, orderbook) are separated by scope, while analysis, trading, portfolio, approval, autonomous loop, and risk tools are each uniquely defined with no meaningful overlap.

    Naming Consistency5/5

    All tool names follow a consistent verb_noun pattern using lowercase with underscores (search_markets, get_market_details, place_order, update_risk_limits). No mixed conventions or camelCase, making the set predictable and easy to navigate.

    Tool Count3/5

    22 tools is in the 16-25 range, which feels heavy even though the domain of autonomous trading justifies a larger surface. While many tools are necessary (market, order, risk, loop management), the count is above the typical 3-15 sweet spot and could potentially be consolidated.

    Completeness4/5

    The tool set covers the full lifecycle of trading: market discovery, analysis, order placement/cancellation, portfolio tracking, risk management, approval modes, and autonomous loop control. Minor gaps like a dedicated trade history tool or explicit sell position are absent, but agents can work around them via existing functionality.

    Maintenance

    ActivityInactive
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables Claude to autonomously trade, analyze, and manage positions on Polymarket prediction markets with 45 comprehensive tools covering market discovery, analysis, trading execution, portfolio management, and real-time monitoring with enterprise-grade safety features.
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      An MCP server and Python toolkit that provides AI agents with real-time tools for Polymarket prediction markets, including liquidity scanning, arbitrage detection, and slippage estimation. It also offers advanced wallet intelligence, portfolio risk calculation, and probabilistic reasoning to enhance market analysis and strategy.
      46 PyPI
      1
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI agents to autonomously trade, analyze, and manage positions on Polymarket prediction markets with 45 tools, real-time WebSocket monitoring, and enterprise-grade safety features.
      MIT