工具:预测市场
搜索市场、读取订单簿和仓位,并在 Polymarket CLOB 上下单或取消订单。
预测市场工具与 Polygon 上 Polymarket 的 CLOB(中央限价订单簿)交互。读取工具无需密钥;写入工具需要策略审批。
search_prediction_markets
通过 Polymarket Gamma API 搜索 Polymarket 事件/市场(无需密钥)。返回结果和 CLOB token_id,可用于交易。
参数
Prop
Type
响应
{
"events": [
{
"title": "2025 US Presidential Election",
"markets": [
{
"question": "Will the Republican nominee win?",
"outcomes": [
{ "name": "Yes", "token_id": "1234567890", "price": 0.55 },
{ "name": "No", "token_id": "9876543210", "price": 0.45 }
]
}
]
}
],
"count": 1
}响应结构仅供参考,实际字段可能有所不同。
示例
{
"query": "bitcoin price",
"limit": 5,
"include_closed": false
}注意事项
- 每个结果返回的
token_id可传入get_prediction_orderbook或place_prediction。 - 使用 Polymarket Gamma API(无需 API 密钥)。
get_prediction_orderbook
获取特定结果 token_id 的 Polymarket CLOB 订单簿(无需密钥读取)。
参数
Prop
Type
响应
{
"token_id": "1234567890",
"bids": [
{ "price": 0.54, "size": 1000.0 },
{ "price": 0.53, "size": 2500.0 }
],
"asks": [
{ "price": 0.56, "size": 800.0 },
{ "price": 0.57, "size": 1500.0 }
],
"mid_price": 0.55
}响应结构仅供参考,实际字段可能有所不同。
示例
{
"token_id": "1234567890"
}注意事项
- 先使用
search_prediction_markets找到要查看的结果对应的token_id。
get_prediction_positions
只读 Polymarket 仓位。使用 Polymarket Data API(无需密钥读取)。
参数
Prop
Type
响应
{
"positions": [
{
"market": "Will BTC exceed $100k by March 2025?",
"outcome": "Yes",
"shares": "50.0",
"avg_price": 0.65,
"current_price": 0.72,
"pnl_usd": 3.5
}
]
}响应结构仅供参考,实际字段可能有所不同。
示例
{
"chain": "polygon"
}注意事项
- 仓位从 Polymarket Data API 获取,无需 API 密钥。
- Polymarket 仓位仅支持 Polygon。
place_prediction
在 Polymarket CLOB 下单。订单在本地构建并签名;通过 Polymarket CLOB API 执行。需要策略审批。
参数
Prop
Type
示例
{
"chain": "polygon",
"token_id": "1234567890",
"side": "buy",
"order_kind": "limit",
"price": "0.55",
"size": "100",
"time_in_force": "gtc"
}以每份额 $0.55 的价格挂出 100 份额的限价买单,有效直至取消。
{
"chain": "polygon",
"token_id": "1234567890",
"side": "buy",
"order_kind": "market",
"amount_usdc": "50"
}以当前市价下市价买单,买入价值 $50 USDC 的份额。
响应
{
"order_id": "0xabcdef...",
"status": "placed",
"filled_size": "0",
"avg_fill_price": null
}响应结构仅供参考,实际字段可能有所不同。
注意事项
- 使用 Polymarket CLOB API(需要 HTTPS 或 localhost)。
- 支持 polygon-amoy 用于测试。
- 限价单需要同时提供
price和size;市价单需要amount_usdc。 - 另见:策略与审批。
close_prediction
通过 order_id 取消现有 Polymarket CLOB 订单。需要策略审批。
参数
Prop
Type
响应
{
"order_id": "0xabcdef...",
"status": "canceled"
}响应结构仅供参考,实际字段可能有所不同。
示例
{
"chain": "polygon",
"order_id": "0xabcdef123456"
}注意事项
- order_id 在
place_prediction下单时返回。 - 另见:策略与审批。