AntiToxicFill
AntiToxicFill detects toxic order-flow patterns on the target market immediately before order submission and reshapes or cancels the ExecutionPlan to
What it does
AntiToxicFill detects toxic order-flow patterns on the target market immediately before order submission and reshapes or cancels the ExecutionPlan to avoid being adversely selected. It monitors three primary toxicity signals: one-sided sweeps through more than three book levels in the last 5 seconds, a cancel-storm on the opposite side, and realised post-fill drift over a rolling window. If an adverse news event is detected within ±30 seconds of a planned fill, the bot enters a cooldown. Depending on signal severity, AntiToxicFill either widens the limit price by requote_widen_bps, reduces the order size by downsize_factor, or cancels the order outright. It cannot alter the trade direction, market, or outcome leg.
Pipeline placement
Applies to: Every pending ExecutionPlan where toxic-flow signals or adverse RiskVotes are present on the target market
Why it matters
| If this fails | Consequence |
|---|---|
| Toxic sweep not detected before submission | The system fills against an informed counterparty that has just swept the book on privileged news, resulting in immediate adverse mark-to-market on the filled position. |
| Cancel-storm ignored on opposite side | Mass cancellations on the opposite side of the book signal that the market is repricing. Submitting a resting order into this environment leads to a fill at a price that is immediately stale. |
| Post-fill drift not tracked across rolling window | Systematic adverse drift after fills indicates chronic toxic flow on the market. Without reshaping, the strategy will continue to be adversely selected until cumulative losses exceed risk limits. |
| News-window cooldown not applied | News events arriving within ±30 seconds of a fill represent the highest toxicity risk. Filling in this window without a cooldown leads to significant slippage on information-driven price moves. |
Inputs
Polymarket inputs
| Input | Source | Required | Use |
|---|---|---|---|
| CLOB V2 order book — top 10 levels both sides | clob_public | required | Detect one-sided sweeps (>3 levels consumed in 5s) and cancel-storms on the opposite side. |
| Recent trade tape (last 100 fills on market) | ws_market | required | Compute realised post-fill drift over the rolling drift_window_s. |
| Market metadata (tick size, neg-risk flag) | clob_public | required | Tick-align the widened requote price after applying requote_widen_bps. |
Internal inputs
| Input | Source | Required | Use |
|---|---|---|---|
| ObservationReport — toxic-flow signals | internal bus (polytraders.reports.execution) | required | Receive structured toxic-flow observations: sweep_detected, cancel_storm_detected, drift_bps, news_event_at_ms. |
| RiskVote — adverse risk signal from guardrail pipeline | risk guardrail pipeline | required | If any RiskVote carries RESHAPE with a toxicity reason, apply downsize_factor to the order size. |
| KillSwitch active flag | KillSwitch | required | Abort order and emit no ExecutionReport if KillSwitch is active. |
| NewsIngest adverse-event feed | internal NewsIngest service | optional | Detect news events within ±news_window_s of the planned fill; enter cooldown_s pause if hit. |
Authority
What this bot is permitted to do
State
Readiness
Limited live
Status
beta
Class
Execution Utility
Default mode
limited_live
Developer owner
Polytraders core — Execution pod
Capital impact
Direct
Reason codes emitted
| Code | Severity | Meaning | Action |
|---|---|---|---|
| ANTITOXICFILL_PASS | INFO | No toxic-flow signals detected; ExecutionPlan passes through unchanged. | Forward ExecutionPlan to signing without modification. |
| ANTITOXICFILL_RESHAPE | RESHAPE | One or more toxic-flow signals (sweep, cancel-storm, or drift) or an adverse RiskVote detected. Price widened by requote_widen_bps and size reduced by downsize_factor. | Apply widen and downsize to ExecutionPlan; forward reshaped plan to signing. |
| ANTITOXICFILL_NEWS_COOLDOWN | HARD_REJECT | An adverse news event was detected within ±news_window_s of the planned fill. Order cancelled; market enters cooldown. | Cancel ExecutionPlan; apply cooldown_s to market_id in Redis; emit no order. |
| ANTITOXICFILL_SWEEP_CANCEL_STORM | HARD_REJECT | Simultaneous one-sided sweep (>3 levels) and cancel-storm on the opposite side detected. Highest toxicity combination; order cancelled and market enters cooldown. | Cancel ExecutionPlan; apply cooldown_s to market_id; emit no order. |
| ANTITOXICFILL_COOLDOWN_ACTIVE | EXPLAIN | This market is currently in a toxicity cooldown from a prior event. New ExecutionPlans are held until the cooldown expires. | Hold ExecutionPlan; re-evaluate after cooldown TTL expires. |
| ANTITOXICFILL_SIZE_FLOOR_APPLIED | WARN | downsize_factor computation would have produced a size below the hard floor (10% of original). Size clamped to 10% of original. | Set reshaped_size_usd = original_size_usd * 0.1; log warning. |
| ANTITOXICFILL_FEED_UNAVAILABLE | WARN | ws_market or clob_public feed unavailable; conservative fallback defaults applied (widen 40 bps, downsize 0.5). | Apply fallback reshape parameters; do not block order entirely. |
| KILL_SWITCH_ACTIVE | HARD_REJECT | Global kill switch is active; no orders may proceed. | Discard ExecutionPlan; emit no order. |
| MARKET_CLOSED | HARD_REJECT | Target market is closed or resolved; ExecutionPlan is invalid. | Discard ExecutionPlan; log and emit no order. |
Related bots in Execution
Used by
Reverse index — strategies that currently reference exec.antitoxicfill. If you change this bot's authority or reason codes, these strategies must re-pass shadow.
| Strategy | State | Activity |
|---|---|---|
| BTC weekly — close-aware quotes | demo-wired | last triggered 40m ago |
| Fed Rates — surprise drift | frozen | last triggered 47m 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 →