Polymarket Agents:为预测市场构建 AI 交易机器人
Polymarket Agents 是一个开源开发者框架,用于构建在 Polymarket 预测市场上自主交易的 AI 智能体。
- Docker
- Go
- Python
- MIT
- 更新于 2026-05-15
AI-Trader:14K⭐ 全自动 AI 交易智能体 • TradingAgents:拥有 82,000 星标的 LLM 多智能体交易框架——2026 年实用指南

Polymarket Agents 是什么? #
Polymarket Agents 是一个开源开发者框架和工具集,用于构建在 Polymarket——全球最大的预测市场平台——上自主交易的 AI 智能体。
这个框架能让开发者:
- 🤖 构建能够分析市场并自动执行交易的 AI 智能体
- 📊 对接 Polymarket API 获取实时市场数据
- 🔍 使用 RAG(检索增强生成)来做出有依据的交易决策
- 📰 从博彩服务、新闻提供商和网页搜索中获取数据
- 🧠 利用全面的 LLM 工具进行提示词工程和市场分析
🔗 GitHub:https://github.com/Polymarket/agents
Polymarket 是什么? #
Polymarket 是一个去中心化预测市场平台,用户在这里针对真实世界事件的结果进行交易:
- 政治 — 选举结果、政策决定
- 加密货币 — 比特币价格预测、ETF 批准
- 体育 — 比赛结果、冠军归属
- 科学 — 研究突破、太空任务
- 娱乐 — 奖项归属、票房结果
交易者根据自己的预测买入"是"或"否"份额,价格反映的是市场对概率的共识。
核心功能 #
| Feature | Description |
|---|---|
| Polymarket API Integration | Full access to market data, order book, and trade execution |
| AI Agent Utilities | Tools for building autonomous trading agents |
| Local & Remote RAG | Vector database support for news and market data retrieval |
| Multi-Source Data | Betting services, news APIs, web search integration |
| LLM Prompt Engineering | Comprehensive tools for context-aware reasoning |
| CLI Interface | Command-line tool for market analysis and trading |
| Docker Support | Containerized deployment for easy setup |
| MIT License | Free and open-source |
架构 #
Polymarket Agents 具有可由社区维护和扩展的模块化组件:
核心 API #
| Component | Purpose |
|---|---|
| Chroma.py | Vector database for news sources and API data |
| Gamma.py | Polymarket Gamma API client for market metadata |
| Polymarket.py | Main API class for market data and trade execution |
| Objects.py | Pydantic data models for trades, markets, events |
CLI 命令 #
与 Polymarket 交互的主要用户界面:
# Get all markets sorted by volume
python scripts/python/cli.py get-all-markets --limit 10 --sort-by volume
# Get specific market details
python scripts/python/cli.py get-market --market-id <MARKET_ID>
# Execute a trade
python scripts/python/cli.py trade --market-id <MARKET_ID> --side buy --size <SIZE>
快速开始 #
1. 克隆仓库 #
git clone https://github.com/polymarket/agents.git
cd agents
2. 配置环境 #
# Create virtual environment
virtualenv --python=python3.9 .venv
source .venv/bin/activate
# Install dependencies
pip install -r requirements.txt
3. 配置 API 密钥 #
创建 .env 文件:
POLYGON_WALLET_PRIVATE_KEY="your-wallet-private-key"
OPENAI_API_KEY="your-openai-api-key"
4. 给钱包充值 USDC #
将 USDC 转入你的 Polygon 钱包用于交易。
5. 运行 CLI #
# Set Python path
export PYTHONPATH="."
# Run CLI
python scripts/python/cli.py
或者直接执行交易:
python agents/application/trade.py
6. Docker 方式 #
./scripts/bash/build-docker.sh
./scripts/bash/run-docker-dev.sh
交易策略 #
Polymarket Agents 支持多种 AI 驱动的交易策略:
1. 基于新闻的交易 #
- 监控新闻来源以追踪事件进展
- 用 LLM 分析情绪与影响
- 根据预测的结果执行交易
2. 套利检测 #
- 比较相关市场之间的价格
- 识别定价错误的概率
- 执行无风险套利交易
3. 趋势跟随 #
- 分析市场成交量和价格变动
- 识别特定市场中的动量
- 顺势而为,从趋势中获利
4. 基本面分析 #
- 研究事件背景与相关因素
- 用 RAG 查询历史数据
- 做出有依据的预测
数据来源 #
该框架集成了多个数据来源:
| Source | Type | Use Case |
|---|---|---|
| News APIs | Real-time news | Event tracking |
| Web Search | General information | Background research |
| Betting Services | Odds comparison | Price discovery |
| Social Media | Sentiment analysis | Trend detection |
| On-Chain Data | Transaction data | Market intelligence |
RAG 实现 #
为做出有依据的交易决策而设计的检索增强生成:
- 向量数据库 — Chroma DB 存储新闻文章和市场数据
- 嵌入 — 将文本转换为向量,用于语义搜索
- 检索 — 根据市场语境查询相关信息
- 生成 — LLM 将检索到的数据综合成交易决策
风险管理 #
自动化交易需要考虑的重要事项:
| Risk | Mitigation |
|---|---|
| Market Risk | Position sizing, stop-losses |
| Liquidity Risk | Trade in high-volume markets |
| Model Risk | Backtest strategies before live trading |
| Operational Risk | Monitor bot performance regularly |
| Regulatory Risk | Comply with local regulations |
与其他工具的比较 #
| Feature | Polymarket Agents | Custom Bot | Manual Trading |
|---|---|---|---|
| Open Source | ✅ | Varies | N/A |
| AI Integration | ✅ | Optional | ❌ |
| RAG Support | ✅ | Rare | ❌ |
| Multi-Source Data | ✅ | Optional | ❌ |
| CLI Interface | ✅ | Varies | N/A |
| Community | ✅ | Varies | ❌ |
| Speed | Fast | Fast | Slow |
| Emotion-Free | ✅ | ✅ | ❌ |
使用场景 #
1. 政治事件交易 #
- 选举结果
- 政策决定
- 立法投票
2. 加密货币市场预测 #
- 比特币价格走势
- ETF 批准
- 监管决定
3. 体育博彩 #
- 比赛结果
- 冠军归属
- 球员表现
4. 娱乐市场 #
- 奖项归属
- 票房预测
- 真人秀结果
相关仓库 #
| Repository | Purpose |
|---|---|
| py-clob-client | Python client for Polymarket CLOB |
| python-order-utils | Order generation and signing |
| clob-client | TypeScript client for CLOB |
| Langchain | Context-aware reasoning |
| Chroma | Vector database |
延伸阅读资源 #
- 预测市场:瓶颈与下一步突破
- 加密货币 + AI 应用,作者 Vitalik Buterin
- 超预测
相关文章 #
- 一个 100 万美元 Polymarket 交易机器人背后的 28 个工具:全栈拆解 — 完整的交易机器人架构
- 免费 Claude Code:免费使用 Claude Code CLI — AI 编程助手
结论 #
Polymarket Agents 为在预测市场上构建 AI 驱动的交易机器人提供了坚实的基础。其模块化架构、全面的 API 集成以及 RAG 能力,使其既适合初学者,也适合经验丰富的开发者。
最适合:对算法交易、预测市场和 AI 驱动决策感兴趣的开发者
GitHub:https://github.com/Polymarket/agents
自托管推荐基础设施 #
如果你想 7x24 小时稳定运行这套技术栈,基础设施的选择很重要:
- DigitalOcean — 覆盖 14 个以上全球区域,60 天内 200 美元免费额度。是运行开源 AI 工具的独立开发者的默认之选。
- HTStack — 从中国大陆访问延迟低的香港 VPS。这与托管 dibi8.com 的 IDC 是同一家——经过生产环境的实战检验。
附属链接——不会给你增加任何费用,同时也帮助维持 dibi8.com 的运营。
最后更新:2026-05-06
💬 留言讨论