RateLimitGovernor
RateLimitGovernor prevents the system from exceeding Polymarket's CLOB order send-rate limits at both the per-market and per-account levels.
What it does
RateLimitGovernor prevents the system from exceeding Polymarket's CLOB order send-rate limits at both the per-market and per-account levels. It reads live rate-limit headers from CLOB responses (X-RateLimit-Remaining, X-RateLimit-Reset), maintains sliding-window counters, and either delays (reshapes) or rejects OrderIntents when the remaining budget falls below configured thresholds. Cancel and risk-flatten requests always receive priority allocation over new open orders. The bot is fail-closed: if rate-limit state cannot be determined, new order intents are rejected until state is re-established.
Pipeline placement
Applies to: Every OrderIntent — checks per-market and per-account order send-rate against Polymarket CLOB limits before allowing exe
Why it matters
| If this fails | Consequence |
|---|---|
| Order send-rate exceeds CLOB limit | Polymarket's CLOB enforces rate limits via Cloudflare. Exceeding the limit produces HTTP 429 responses, which cause order rejections, increased latency, and potential temporary IP/key bans that block all trading — including urgent risk-flatten operations. |
| No priority for cancel/risk-flatten requests | If rate budget is exhausted by new open orders, urgent cancellation or position-flatten requests may be queued or dropped, leaving dangerous open exposure during fast market moves. |
| Rate budget not read from live CLOB headers | Hard-coded rate limits may diverge from Polymarket's actual published limits. Reading live headers ensures the system adapts to any policy changes without a code deploy. |
| Per-market throttle not separated from per-account throttle | A high-frequency strategy on one market can exhaust the account's global rate budget, silently starving other markets of order capacity. |
Inputs
Polymarket inputs
| Input | Source | Required | Use |
|---|---|---|---|
| CLOB rate-limit response headers: X-RateLimit-Remaining, X-RateLimit-Reset, X-RateLimit-Limit | clob_auth | required | Track the live remaining request budget and reset time per sliding window. Update internal counters after every CLOB response. |
Internal inputs
| Input | Source | Required | Use |
|---|---|---|---|
| Per-market sliding-window order counter | internal | required | Count the number of order intents sent to each market within the current rate-limit window. |
| Per-account global order counter | internal | required | Count total order intents across all markets to enforce the account-level rate cap. |
| Intent classification: open / cancel / risk-flatten | internal | required | Cancel and risk-flatten intents always receive priority allocation from the reserved cancel budget; they bypass the standard rate check. |
| KillSwitch active flag | KillSwitch | required | If KillSwitch is active, reject all new open orders immediately. Cancel/flatten requests still use the priority path. |
Authority
What this bot is permitted to do
State
Readiness
General live
Status
live
Class
Guardrail
Default mode
general_live
Developer owner
Polytraders core — Risk pod
Capital impact
Direct
Reason codes emitted
| Code | Severity | Meaning | Action |
|---|---|---|---|
| KILL_SWITCH_ACTIVE | HARD_REJECT | Global kill switch is active; all open-order intents are rejected. Cancel and risk-flatten intents are unaffected. | Return HARD_REJECT for OPEN intents; CANCEL and RISK_FLATTEN intents proceed via priority path. |
| RATE_LIMIT_GOVERNOR_BUDGET_EXHAUSTED | HARD_REJECT | Account-level trading counter has reached the hard limit for the current sliding window. | Return HARD_REJECT; log window reset time. Intent may be requeued after window reset. |
| RATE_LIMIT_GOVERNOR_MARKET_THROTTLED | HARD_REJECT | Per-market order counter has reached the per-market sub-limit for the current window. | Return HARD_REJECT for this market; intents on other markets are unaffected. |
| RATE_LIMIT_GOVERNOR_BUDGET_WARN | RESHAPE | Trading counter is in the warning zone (80–100% of limit). Order deferred until window reset. | Return RESHAPE_REQUIRED with constraints.defer_ms = ms until window reset. |
| RATE_LIMIT_GOVERNOR_STATE_UNKNOWN | HARD_REJECT | Internal rate-limit state is uninitialised or cannot be read; fail-closed to prevent accidental over-sending. | Return HARD_REJECT for all non-priority intents until state is re-established from CLOB headers. |
| RATE_LIMIT_GOVERNOR_PRIORITY_CANCEL | INFO | Cancel intent approved from reserved cancel budget, bypassing the standard trading counter. | Decrement reserved cancel budget; emit APPROVE. |
| RATE_LIMIT_GOVERNOR_PRIORITY_FLATTEN | INFO | Risk-flatten intent approved unconditionally, bypassing all rate counters. | Emit APPROVE without touching any counter. |
| RATE_LIMIT_GOVERNOR_PASS | INFO | Both per-market and per-account counters are within limits. Intent approved. | Increment counters; emit APPROVE. |
Related bots in Risk Guardrail
Used by
Reverse index — strategies that currently reference risk.ratelimitgovernor. If you change this bot's authority or reason codes, these strategies must re-pass shadow.
| Strategy | State | Activity |
|---|---|---|
| NBA props — line-shop | demo-wired | last triggered 21m ago |
| Crypto Q2 — basket rebalance | frozen | last triggered 28m ago |
| US Elect — book-builder | demo-wired | last triggered 35m ago |
Showing 3 of 3 · demo-wired ≠ production-live
Why this matters
Risk Guardrail bots does NOT propose intents or sign orders; only permits or blocks. Understanding the authority boundary prevents misuse and makes promotion-gate reviews faster and more reliable. View raw spec JSON →