Documentation Index
Fetch the complete documentation index at: https://docs.polymarket.com/llms.txt
Use this file to discover all available pages before exploring further.
Polymarket 撮合引擎会重启以进行维护和升级。本页介绍如何检测和处理停机、重启后的 post-only 阶段以及如何获取变更的提前通知。
撮合引擎变更——计划重启、更新和维护窗口——会在发生之前在以下渠道公告:
Telegram
加入 Polymarket Trading APIs 频道获取实时公告。
Discord
加入 Polymarket Discord 的 #trading-apis 频道。
公告通常包括变更内容、计划时间和预计停机窗口。目标是尽可能提前约 2 天通知。
处理 HTTP 425
在重启窗口期间,CLOB API 在所有订单相关端点上返回 HTTP 425(Too Early)。这告诉你的客户端撮合引擎正在重启,很快会恢复。
每次重启后,撮合引擎都会进入 2 分钟的 post-only 模式。在此期间,取消请求会被接受,新订单必须设置 postOnly: true;非 post-only 订单会被拒绝。
建议的重试策略
检测 425
当收到 HTTP 425 响应时,撮合引擎正在重启。不要将其视为永久错误。
退避并重试
等待并使用指数退避重试。从 1-2 秒开始,每次重试增加间隔。
处理 post-only 模式
一旦不再收到 425 响应,引擎已恢复在线,但仍会保持 2 分钟的 post-only 模式。在此期间,只接受取消请求和设置了 postOnly: true 的订单。
代码示例
检查 CLOB API 响应的 HTTP 状态码,在收到 425 时重试:
const CLOB_HOST = "https://clob.polymarket.com";
async function postWithRetry(path: string, body: any, headers: Record<string, string>) {
const MAX_RETRIES = 10;
let delay = 1000;
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
const response = await fetch(`${CLOB_HOST}${path}`, {
method: "POST",
headers: { "Content-Type": "application/json", ...headers },
body: JSON.stringify(body),
});
if (response.status === 425) {
console.log(`Engine restarting, retrying in ${delay / 1000}s...`);
await new Promise((r) => setTimeout(r, delay));
delay = Math.min(delay * 2, 30000);
continue;
}
return response;
}
throw new Error("Engine restart exceeded maximum retry attempts");
}
受限交易模式
在受限交易模式下,POST /order 和 POST /orders 的下单行为会发生变化。除非交易被完全禁用,取消端点仍会接受取消请求。
仅取消模式
在仅取消模式下,新订单会被拒绝,但取消请求仍会被接受。
POST /order 和 POST /orders 返回 503:
{
"error": "Trading is currently cancel-only. New orders are not accepted, but cancels are allowed."
}
Post-Only 模式
每次重启后,撮合引擎都会进入 2 分钟的 post-only 模式。取消请求会被接受,新订单必须设置 postOnly: true。非 post-only 订单会被拒绝。
POST /order 返回 503,并在响应体和 Retry-After HTTP header 中提供重试延迟:
{
"error": "post-only mode: only post-only orders and cancels are allowed",
"code": "post_only_mode",
"retry_after_seconds": 79
}
POST /orders 会对批量请求中的每个非 post-only 订单返回单独的错误:
[
{
"errorMsg": "post-only mode: only post-only orders and cancels are allowed",
"orderID": "",
"takingAmount": "",
"makingAmount": "",
"status": "",
"success": true
},
{
"errorMsg": "post-only mode: only post-only orders and cancels are allowed",
"orderID": "",
"takingAmount": "",
"makingAmount": "",
"status": "",
"success": true
}
]
收到任一受限模式响应时,不要原样重试同一个非 post-only 订单。你可以取消现有订单、在提供重试延迟时等待后再重试,或使用 postOnly: true 重新提交符合条件的 maker 订单。
最佳实践
- 订阅公告渠道 — 在重启发生前获得通知,以便做好准备
- 优雅处理 425 — 将其视为临时状况而非错误;你的重试逻辑应自动恢复
- 处理下单端点的 503 模式响应 — 仅取消和 post-only 响应需要调整订单流程,而不是盲目重试
- 避免激进重试 — 引擎需要时间重新加载订单簿;快速重试不会加快速度,反而可能在引擎恢复后触发速率限制
- 记录重启事件 — 跟踪客户端遇到 425 的时间,与公告的维护窗口进行关联