CancelReplaceOptimizer
CancelReplaceOptimizer selects the cheapest path to modify a resting order: amend-in-place if queue priority is preserved, or cancel-then-replace if t
What it does
CancelReplaceOptimizer selects the cheapest path to modify a resting order: amend-in-place if queue priority is preserved, or cancel-then-replace if the delta exceeds the amend threshold. It enforces rate-limit budgets across cancel and amend operations.
Pipeline placement
Applies to: Any request to modify a resting order's price or size
Why it matters
| If this fails | Consequence |
|---|---|
| Always using cancel-then-replace | Loses queue position on every requote, resulting in consistently worse fills on passive strategies where queue position matters. |
| Amend threshold set too wide | Large price changes that would trigger queue-position loss are processed as amends, causing the strategy to hold a stale order at a position that was meant to be cancelled. |
| Rate limit not enforced across cancels | A burst of cancel-replace operations hits the CLOB V2 rate limit, causing 429 errors and leaving orders unmodified at stale prices. |
Inputs
Polymarket inputs
| Input | Source | Required | Use |
|---|---|---|---|
| CLOB V2 amend endpoint semantics | clob_auth | required | Determine whether amend preserves queue priority for the given price/size delta. |
| Market tick size | clob_public | required | Compute tick distance between current and target price for amend vs. cancel-replace decision. |
Internal inputs
| Input | Source | Required | Use |
|---|---|---|---|
| Requote instruction with current order_id, target price, target size | exec.partialfillhandler or strat layer | required | Receive the requested modification and current order parameters. |
| Rate-limit budget state | internal rate-limit tracker | required | Check remaining cancel and amend budget before issuing operations. |
Authority
What this bot is permitted to do
State
Readiness
Spec started
Status
planned
Class
Execution Utility
Default mode
shadow_only
Developer owner
Polytraders core — Execution pod
Capital impact
Direct
Reason codes emitted
| Code | Severity | Meaning | Action |
|---|---|---|---|
| AMEND_IN_PLACE | INFO | Order amended without cancelling; queue priority preserved. | Emit ExecutionReport; no further action. |
| CANCEL_REPLACE_EXECUTED | INFO | Order cancelled and resubmitted at new price/size. | Emit ExecutionReport. |
| CANCEL_REPLACE_FORCED | RESHAPE | Delta exceeds amend_threshold_ticks; cancel-replace forced. | Cancel and resubmit. |
| CANCEL_REPLACE_RATE_LIMIT_SHED | WARN | burst_max_per_s exceeded; request shed. | Drop request; emit WARN; retry on next tick. |
| KILL_SWITCH_ACTIVE | HARD_REJECT | KillSwitch active; no cancel or amend operations. | Halt all operations. |
Related bots in Execution
Used by
Reverse index — strategies that currently reference exec.cancelreplaceoptimizer. 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 39m ago |
| Crypto Q2 — basket rebalance | frozen | last triggered 46m ago |
Showing 2 of 2 · demo-wired ≠ production-live
Why this matters
Execution bots does NOT propose new positions; only routes and shapes approved intents. Understanding the authority boundary prevents misuse and makes promotion-gate reviews faster and more reliable. View raw spec JSON →