polymarket
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePolymarket Comprehensive Skill
Polymarket 综合技能指南
Complete assistance with Polymarket development - covering the full platform (API, trading, market data) and the real-time data streaming client (WebSocket subscriptions for live market activity).
为Polymarket开发提供全方位支持——涵盖整个平台(API、交易、市场数据)以及实时数据流客户端(用于市场实时活动的WebSocket订阅)。
When to Use This Skill
何时使用本技能
This skill should be triggered when:
Platform & API:
- Working with Polymarket prediction markets
- Using Polymarket API for market data
- Implementing trading strategies
- Building applications with Polymarket services
- Learning Polymarket best practices
Real-Time Data Streaming:
- Connecting to Polymarket's WebSocket service
- Building prediction market monitoring tools
- Processing live trades, orders, and market updates
- Monitoring market comments and social reactions
- Tracking RFQ (Request for Quote) activity
- Integrating crypto price feeds
本技能适用于以下场景:
平台与API:
- 开发Polymarket预测市场相关功能
- 使用Polymarket API获取市场数据
- 实现交易策略
- 基于Polymarket服务构建应用
- 学习Polymarket最佳实践
实时数据流:
- 连接Polymarket的WebSocket服务
- 构建预测市场监控工具
- 处理实时交易、订单和市场更新
- 监控市场评论和社交互动
- 跟踪RFQ(询价)活动
- 集成加密货币价格数据源
Quick Reference
快速参考
Real-Time Data Client Setup
实时数据客户端设置
Installation:
bash
npm install @polymarket/real-time-data-clientBasic Usage:
typescript
import { RealTimeDataClient } from "@polymarket/real-time-data-client";
const onMessage = (message: Message): void => {
console.log(message.topic, message.type, message.payload);
};
const onConnect = (client: RealTimeDataClient): void => {
client.subscribe({
subscriptions: [{
topic: "activity",
type: "trades"
}]
});
};
new RealTimeDataClient({ onMessage, onConnect }).connect();安装:
bash
npm install @polymarket/real-time-data-client基础用法:
typescript
import { RealTimeDataClient } from "@polymarket/real-time-data-client";
const onMessage = (message: Message): void => {
console.log(message.topic, message.type, message.payload);
};
const onConnect = (client: RealTimeDataClient): void => {
client.subscribe({
subscriptions: [{
topic: "activity",
type: "trades"
}]
});
};
new RealTimeDataClient({ onMessage, onConnect }).connect();Supported WebSocket Topics
支持的WebSocket主题
1. Activity ()
activity- - Completed trades
trades - - Order matching events
orders_matched - Filters: OR
{"event_slug":"string"}{"market_slug":"string"}
2. Comments ()
comments- ,
comment_createdcomment_removed - ,
reaction_createdreaction_removed - Filters:
{"parentEntityID":number,"parentEntityType":"Event"}
3. RFQ ()
rfq- Request/Quote lifecycle events
- No filters, no auth required
4. Crypto Prices (, )
crypto_pricescrypto_prices_chainlink- - Real-time price feeds
update - Filters: (optional)
{"symbol":"BTC"}
5. CLOB User () ⚠️ Requires Auth
clob_user- - User's order updates
order - - User's trade executions
trade
6. CLOB Market ()
clob_market- - Price movements
price_change - - Aggregated order book
agg_orderbook - - Latest prices
last_trade_price - ,
market_createdmarket_resolved
1. 活动()
activity- - 已完成的交易
trades - - 订单匹配事件
orders_matched - 过滤器:或
{"event_slug":"string"}{"market_slug":"string"}
2. 评论()
comments- ,
comment_createdcomment_removed - ,
reaction_createdreaction_removed - 过滤器:
{"parentEntityID":number,"parentEntityType":"Event"}
3. RFQ(询价)
- 询价全生命周期事件
- 无需过滤器和认证
4. 加密货币价格(, )
crypto_pricescrypto_prices_chainlink- - 实时价格数据
update - 过滤器:(可选)
{"symbol":"BTC"}
5. CLOB 用户() ⚠️ 需要认证
clob_user- - 用户订单更新
order - - 用户交易执行记录
trade
6. CLOB 市场()
clob_market- - 价格变动
price_change - - 聚合订单簿
agg_orderbook - - 最新成交价
last_trade_price - ,
market_createdmarket_resolved
Authentication for User Data
用户数据认证
typescript
client.subscribe({
subscriptions: [{
topic: "clob_user",
type: "*",
clob_auth: {
key: "your-api-key",
secret: "your-api-secret",
passphrase: "your-passphrase"
}
}]
});typescript
client.subscribe({
subscriptions: [{
topic: "clob_user",
type: "*",
clob_auth: {
key: "your-api-key",
secret: "your-api-secret",
passphrase: "your-passphrase"
}
}]
});Common Use Cases
常见使用场景
Monitor Specific Market:
typescript
client.subscribe({
subscriptions: [{
topic: "activity",
type: "trades",
filters: `{"market_slug":"btc-above-100k-2024"}`
}]
});Track Multiple Markets:
typescript
client.subscribe({
subscriptions: [{
topic: "clob_market",
type: "price_change",
filters: `["100","101","102"]`
}]
});Monitor Event Comments:
typescript
client.subscribe({
subscriptions: [{
topic: "comments",
type: "*",
filters: `{"parentEntityID":12345,"parentEntityType":"Event"}`
}]
});监控特定市场:
typescript
client.subscribe({
subscriptions: [{
topic: "activity",
type: "trades",
filters: `{"market_slug":"btc-above-100k-2024"}`
}]
});跟踪多个市场:
typescript
client.subscribe({
subscriptions: [{
topic: "clob_market",
type: "price_change",
filters: `["100","101","102"]`
}]
});监控活动评论:
typescript
client.subscribe({
subscriptions: [{
topic: "comments",
type: "*",
filters: `{"parentEntityID":12345,"parentEntityType":"Event"}`
}]
});Reference Files
参考文档
This skill includes comprehensive documentation in :
references/Platform Documentation:
- api.md - Polymarket API documentation
- getting_started.md - Getting started guide
- guides.md - Development guides
- learn.md - Learning resources
- trading.md - Trading documentation
- other.md - Additional resources
Real-Time Client:
- README.md - WebSocket client API and examples
- llms.md - LLM integration guide
- llms-full.md - Complete LLM documentation
Use to read specific reference files for detailed information.
view本技能在目录下包含完整文档:
references/平台文档:
- api.md - Polymarket API 文档
- getting_started.md - 入门指南
- guides.md - 开发指南
- learn.md - 学习资源
- trading.md - 交易相关文档
- other.md - 其他资源
实时客户端:
- README.md - WebSocket 客户端API及示例
- llms.md - LLM集成指南
- llms-full.md - 完整LLM文档
使用命令查看特定参考文件以获取详细信息。
viewKey Features
核心功能
Platform Capabilities:
✅ Prediction market creation and resolution
✅ Trading API (REST & WebSocket)
✅ Market data queries
✅ User portfolio management
✅ Event and market discovery
Real-Time Streaming:
✅ WebSocket-based persistent connections
✅ Topic-based subscriptions
✅ Dynamic subscription management
✅ Filter support for targeted data
✅ User authentication for private data
✅ TypeScript with full type safety
✅ Initial data dumps on connection
平台能力:
✅ 预测市场的创建与结算
✅ 交易API(REST & WebSocket)
✅ 市场数据查询
✅ 用户投资组合管理
✅ 活动与市场发现
实时数据流:
✅ 基于WebSocket的持久连接
✅ 基于主题的订阅
✅ 动态订阅管理
✅ 支持过滤器以获取目标数据
✅ 用户认证以访问私有数据
✅ 带完整类型安全的TypeScript支持
✅ 连接时的初始数据导出
Best Practices
最佳实践
WebSocket Connection Management
WebSocket连接管理
- Use callback for subscriptions
onConnect - Implement reconnection logic for production
- Clean up with when done
disconnect() - Handle authentication errors gracefully
- 使用回调进行订阅
onConnect - 为生产环境实现重连逻辑
- 使用完毕后调用清理连接
disconnect() - 优雅处理认证错误
Subscription Strategy
订阅策略
- Use wildcards () sparingly
"*" - Apply filters to reduce data volume
- Unsubscribe from unused streams
- Process messages asynchronously
- 谨慎使用通配符()
"*" - 应用过滤器以减少数据量
- 取消订阅不再使用的数据流
- 异步处理消息
Performance
性能优化
- Consider batching high-frequency data
- Use filters to minimize client processing
- Validate message payloads before use
- 考虑对高频数据进行批量处理
- 使用过滤器减少客户端处理压力
- 使用前验证消息负载
Requirements
环境要求
- Node.js: 14+ recommended
- TypeScript: Optional but recommended
- Package Manager: npm or yarn
- Node.js: 推荐14+版本
- TypeScript: 可选但推荐使用
- 包管理器: npm 或 yarn
Resources
资源
Official Links
官方链接
- Polymarket Platform: https://polymarket.com
- Real-Time Client Repo: https://github.com/Polymarket/real-time-data-client
- API Documentation: See references/api.md
- Polymarket平台: https://polymarket.com
- 实时客户端仓库: https://github.com/Polymarket/real-time-data-client
- API文档: 详见 references/api.md
Working with This Skill
如何使用本技能
For Beginners:
Start with for foundational concepts.
getting_started.mdFor API Integration:
Use and for REST API details.
api.mdtrading.mdFor Real-Time Data:
Use for WebSocket client implementation.
README.mdFor LLM Integration:
Use and for AI/ML use cases.
llms.mdllms-full.md面向初学者:
从开始学习基础概念。
getting_started.md面向API集成开发者:
使用和获取REST API详细信息。
api.mdtrading.md面向实时数据开发者:
使用实现WebSocket客户端。
README.md面向LLM集成开发者:
使用和获取AI/ML相关用例。
llms.mdllms-full.mdNotes
注意事项
- Real-Time Client is TypeScript/JavaScript (not Python)
- Some WebSocket topics require authentication
- Use filters to manage message volume effectively
- All timestamps are Unix timestamps
- Market IDs are strings (e.g., "100", "101")
- Platform documentation covers both REST API and WebSocket usage
This comprehensive skill combines Polymarket platform expertise with real-time data streaming capabilities!
- 实时客户端基于TypeScript/JavaScript(不支持Python)
- 部分WebSocket主题需要认证
- 有效使用过滤器管理消息量
- 所有时间戳均为Unix时间戳
- 市场ID为字符串(例如:"100", "101")
- 平台文档同时涵盖REST API和WebSocket使用方法
本综合技能结合了Polymarket平台能力与实时数据流功能!