Skip to content

Latest commit

 

History

History
172 lines (133 loc) · 4.85 KB

File metadata and controls

172 lines (133 loc) · 4.85 KB
name clawpoly
description Polymarket prediction market trading bot with Kelly criterion position sizing and multi-strategy scanning
homepage https://github.com/OpenKrab/ClawPoly
user-invocable true
metadata
openclaw
emoji requires primaryEnv
📊
bins env
python
CLAUPOLY_PRIVATE_KEY
CLAUPOLY_PRIVATE_KEY

ClawPoly — Polymarket Trading Bot Skill

Integrate ClawPoly into OpenClaw agents to monitor and trade on Polymarket prediction markets. The bot scans 7500+ markets, identifies mispricings via multiple strategies (Value Betting, Cross Arbitrage, Market Making, Momentum), and sizes positions using Kelly Criterion.

Installation

The skill is part of the ClawPoly repository. Ensure:

  1. Python 3.13+ is installed and on PATH:

    python --version
  2. ClawPoly is installed in {baseDir}:

    cd {baseDir}
    pnpm install
    pnpm build
  3. Environment variables in ~/.openclaw/openclaw.json:

    {
      "skills": {
        "entries": {
          "clawpoly": {
            "enabled": true,
            "apiKey": { "source": "env", "provider": "default", "id": "CLAUPOLY_PRIVATE_KEY" },
            "env": {
              "CLAUPOLY_PRIVATE_KEY": "<your_private_key_here>"
            }
          }
        }
      }
    }

Setup

1. Create .env file in {baseDir}:

POLYGMARKET_WALLET_ADDRESS=0x...
POLYMARKET_PRIVATE_KEY=<private_key>
POLY_SCAN_INTERVAL=60
POLY_DRY_RUN=false

2. Configure risk profile in {baseDir}/moltbot.json:

{
  "risk": {
    "level": "moderate",
    "max_position_pct": 10,
    "max_concurrent": 5,
    "min_edge_pct": 3,
    "stop_loss_pct": 0.30
  }
}

Commands

Invoke via the nodes.run tool or direct shell execution:

Check Balance & Positions

python {baseDir}/src/main.py balance

Shows USDC balance and open positions with P&L.

Scan for Opportunities

python {baseDir}/src/main.py scan

Scan all active markets without placing trades. Returns opportunities ranked by edge.

Browse Markets

python {baseDir}/src/main.py markets [--search <query>]

Browse active Polymarket categories or search specific markets.

Run Live Trading Loop

python {baseDir}/src/main.py run --risk <conservative|moderate|aggressive>

Start continuous scan → trade loop. Respects risk limits, Kelly sizing, and position caps.

View Trade History

python {baseDir}/src/main.py history

Display all executed trades, P&L, and realized gains/losses.

Show Configuration

python {baseDir}/src/main.py config

Display current risk settings, wallet, and strategy config.

Strategies

The bot supports four trading strategies:

  • Value Betting: Identifies mispriced events where outcome probabilities don't sum to 1.0
  • Cross Arbitrage: Exploits price differences across related markets
  • Market Making: Provides liquidity in high-volume markets (future)
  • Momentum: Follows recent price trends (future)

Risk Management

All trades are gated by:

  1. Kelly Criterion: Position sizes = bankroll × edge ÷ odds (fractionally reduced to 75%)
  2. Max Position %: Cap per-trade exposure (configurable by risk level)
  3. Max Concurrent: Limit simultaneous positions (5–20 depending on risk)
  4. Stop Loss: Auto-close positions exceeding 30% loss
  5. Portfolio Guard: Minimum $0.50 balance required; halts trading if below

Configuration Profiles

Conservative:  5% max position, 3 concurrent, 2% min edge
Moderate:      10% max position, 5 concurrent, 3% min edge
Aggressive:    20% max position, 10 concurrent, 1% min edge

Security Notes

⚠️ Never hardcode private keys. Always use:

  • Environment variables (CLAUPOLY_PRIVATE_KEY)
  • .env file (gitignored)
  • Secret management via ~/.openclaw/openclaw.json → config.apiKey

Private key exposure = full wallet compromise. If exposed, transfer funds immediately.

Example Usage in Agent

User: "Show me current positions on Polymarket"
Agent: Runs `python {baseDir}/src/main.py balance` → displays holdings

User: "Scan for arbitrage opportunities"
Agent: Runs `python {baseDir}/src/main.py scan` → lists 900+ signals

User: "Start trading with moderate risk"
Agent: Runs `python {baseDir}/src/main.py run --risk moderate` → begins loop

Troubleshooting

"balance too low" error: Deposit USDC to wallet (min $0.50):

  1. Bridge USDC from Ethereum → Polygon
  2. Or buy USDC on Polygon via CEX (Coinbase, Kraken, Crypto.com)

API rate limits: Reduce POLY_SCAN_INTERVAL or check Gamma API status.

Wrong strategy signals: Review src/strategies/<strategy>/ for trigger conditions.

References