Skip to content
Back to skills

Polymarket Prediction Agents

ASecurity

AI agent framework for autonomous trading on Polymarket prediction markets. Connects LLMs to Polymarket's DEX via Gamma API, supports RAG with Chroma DB, integrates news/betting/web-search data sources. Uses py-clob-client for on-chain order executio

  • 14 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added June 3, 2026
ai-agentspythongobashgitapi

Works with

  • cli
  • api

Security analysis

A96/100
  • mediumInstalls packages at runtime which could introduce malicious dependencies

Pro shows the line behind each finding and how to fix it

Scanned June 3, 2026

npx -y skills add mahmoud20138/Tradecraft --skill polymarket-prediction-agents --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Polymarket Prediction Agents?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Polymarket Prediction Agents
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/mahmoud20138-polymarket-prediction-agents/badge)](https://www.skillsdirectory.com/skills/mahmoud20138-polymarket-prediction-agents)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: polymarket-prediction-agents
description: AI agent framework for autonomous trading on Polymarket prediction markets. Connects LLMs to Polymarket's DEX via Gamma API, supports RAG with Chroma DB, integrates news/betting/web-search data sources. Uses py-clob-client for on-chain order executio
kind: agent
category: trading/ai-agents
status: active
tags: [ai-agents, ai-agents, ict, news, polymarket, prediction, trading]
related_skills: [ai-trading-crew, autohedge-swarm, freqtrade-bot, openalice-trading-agent, ritmex-crypto-agent]
---

# polymarket-prediction-agents

USE FOR:
  - "trade on prediction markets with AI"
  - "Polymarket agent / bot"
  - "prediction market analysis with LLM"
  - "autonomous betting / event trading agent"
  - "RAG-powered market research pipeline"
  - "crypto prediction market automation"
tags: [polymarket, prediction-markets, crypto, DeFi, agents, LLM, RAG, Polygon, CLOB]
kind: framework
category: crypto-defi-trading

---

## What Is Polymarket Agents?

Developer framework for building autonomous AI agents that trade on **Polymarket** —
a decentralized prediction market platform on Polygon.

- Repo: https://github.com/Polymarket/agents
- License: MIT
- Runtime: Python 3.9
- **Note**: US persons and restricted jurisdictions cannot trade per ToS

---

## Architecture

```
┌──────────────── DATA LAYER ──────────────────┐
│  Gamma API       → market metadata & events   │
│  News providers  → relevant articles          │
│  Web search      → real-time information      │
│  Betting APIs    → odds & market sentiment    │
└───────────────────────┬──────────────────────┘
                        ↓
┌──────────────── AI LAYER ────────────────────┐
│  LLM (OpenAI / any)  → reasoning             │
│  RAG (Chroma DB)     → vectorized context    │
│  Prompt utilities    → structured queries    │
└───────────────────────┬──────────────────────┘
                        ↓
┌──────────────── EXECUTION LAYER ─────────────┐
│  py-clob-client  → CLOB order generation     │
│  Polygon wallet  → on-chain signing          │
│  Polymarket DEX  → order execution           │
└──────────────────────────────────────────────┘
```

---

## Installation

```bash
git clone https://github.com/Polymarket/agents.git
cd agents
virtualenv --python=python3.9 .venv
source .venv/bin/activate
pip install -r requirements.txt
cp .env.example .env
```

**`.env` Configuration:**
```bash
POLYGON_WALLET_PRIVATE_KEY="0x..."   # Polygon wallet for trading
OPENAI_API_KEY="sk-..."              # LLM provider
POLYMARKET_API_KEY="..."             # Optional: API key tier
```

---

## CLI Usage

```bash
# List markets by volume
python scripts/python/cli.py get-all-markets --limit 5 --sort-by volume

# Get specific event
python scripts/python/cli.py get-market --market-id <id>

# Search markets by keyword
python scripts/python/cli.py get-markets --keyword "election" --limit 10
```

---

## Trading Execution

```python
# Run autonomous trading agent
python agents/application/trade.py

# The agent will:
# 1. Fetch current markets via Gamma API
# 2. Retrieve relevant news + RAG context
# 3. Query LLM for probability assessment
# 4. Compare to market price → find edge
# 5. Sign + submit order via py-clob-client
```

---

## RAG Integration

```python
from agents.utils.chroma import ChromaClient

# Vectorize news articles for retrieval
client = ChromaClient()
client.add_documents(news_articles)

# Query for market-relevant context
results = client.query("US election 2026 polling", n_results=5)
```

---

## Prediction Market Edge Formula

```
Edge = Estimated_Probability - Market_Price

If Edge > threshold → BUY YES / NO token
If Edge < -threshold → SELL or BUY opposite
```

LLM assesses probability from news + context; market price is the current token price (0–1).

---

## Key Components

| Component | Description |
|-----------|-------------|
| `Gamma API` | Polymarket's REST API for markets/events data |
| `py-clob-client` | Order book client for CLOB trading |
| `Chroma DB` | Vector store for RAG-based news retrieval |
| `Prompt utils` | LLM prompt engineering helpers |
| `trade.py` | Main agent execution loop |
| `cli.py` | CLI for market exploration |

---

## Extending the Agent

```python
# Custom analyst agent pattern
class MyPredictionAgent:
    def analyze(self, market: dict) -> float:
        context = self.rag.query(market["question"])
        news = self.news_api.get_recent(market["question"])
        
        prompt = f"""
        Question: {market['question']}
        Context: {context}
        News: {news}
        Current market price: {market['price']}
        
        Estimate the true probability (0-1) and justify.
        """
        response = self.llm.complete(prompt)
        return self.parse_probability(response)
```


---

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.