Polymarket Agents
Trade autonomously on Polymarket using AI Agents
A developer framework and set of utilities for building AI agents that trade autonomously on Polymarket prediction markets. Integrates with Polymarket API, supports RAG for data sourcing from news and betting services, and provides LLM tools for prompt engineering.
Overview
Overview
Polymarket Agents is a developer framework for building AI agents that trade autonomously on Polymarket prediction markets. The framework provides modular components for market data retrieval, order execution, and AI-driven decision-making.
Architecture
The system features modular APIs and connectors:
- Gamma API Client: Fetches and parses market and event metadata from Polymarket Gamma API
- Polymarket API Client: Retrieves market data, manages events, and executes trades on the Polymarket DEX
- Chroma Integration: Vector database for storing and querying news sources and API data
- Data Models: Pydantic-based representations for trades, markets, events, and related entities
Data Sourcing
Agents leverage retrieval-augmented generation (RAG) to inform trading decisions. The framework supports:
- Local and remote RAG implementations
- News provider integration
- Betting service data
- Web search capabilities
- Vector storage via Chroma for efficient retrieval
Command Line Interface
The CLI (cli.py) provides commands for market queries, news retrieval, LLM interactions, and trade execution. Example: get-all-markets retrieves markets sorted by volume with configurable limits.
Deployment
Supports local Python execution or Docker-based deployment. Requires Python 3.9, a funded USDC wallet on Polygon, and API keys for OpenAI and Polymarket services.
Primitives
Retrieves market and event data from Polymarket
Executes trades on Polymarket DEX
Sources data from news providers and web search
Performs retrieval-augmented generation (RAG)
Builds and signs orders programmatically
Queries local vector databases
Interfaces with LLMs for decision-making
Outcomes
- 01Autonomous trading on prediction markets
- 02Data-driven market analysis
- 03Executed buy/sell orders on Polymarket
Integrations
Autonomy & guardrails
- Operates within Polymarket Terms of Service restrictions
- Requires initial wallet setup and funding
- Uses configured API keys for external services
Guardrails & requirements
Guardrails
- Geographic restrictions per Polymarket Terms of Service
- Private key management required
- USDC wallet funding required
Requirements
- Python 3.9
- POLYGON_WALLET_PRIVATE_KEY environment variable
- OPENAI_API_KEY environment variable
- USDC-funded wallet
Technical specifications
Runtime
- Harness
- Custom
- Deployment
- Self-hosted (local or Docker)
- License
- MIT
Models & tooling
- Models
- OpenAI models (via OPENAI_API_KEY)
- Tooling
- Pydantic for data modelsChroma for vector storagepy-clob-client for Polymarket CLOBpython-order-utils for order signingLangchain utilities
Security & compliance
- Auth model
- Private key-based wallet authentication for Polygon; API key authentication for OpenAI and Polymarket
Architecture notes
Memory architecture
Vector database (Chroma) for news sources and API data
Context strategy
Retrieval-augmented generation (RAG) from vectorized news and market data