Skip to main content

Slippage Protection

PolySimulator uses the same slippage protection model as Polymarket: the price field on every market order acts as a worst-price limit. There is no separate slippage parameter — the price is your slippage protection.

How It Works

On Polymarket, all orders are limit orders. A “market order” is simply a limit order at a marketable price with FOK (Fill-or-Kill) time-in-force. PolySimulator mirrors this exactly. The price field is required on market orders and sets the worst price you’ll accept:
  • BUY: fills at the best ask, but never above your price
  • SELL: fills at the best bid, but never below your price
{
  "market_id": "0xabc...",
  "side": "BUY",
  "outcome": "Yes",
  "quantity": "10",
  "order_type": "market",
  "price": "0.68"
}

BUY Example

Best ask:    $0.65
Your limit:  $0.68
→ FILLED at $0.65 (price improvement — you pay less than your limit)

Best ask:    $0.72
Your limit:  $0.68
→ REJECTED — fill price $0.72 exceeds your worst-price limit $0.68

SELL Example

Best bid:    $0.60
Your limit:  $0.55
→ FILLED at $0.60 (price improvement — you receive more than your limit)

Best bid:    $0.50
Your limit:  $0.55
→ REJECTED — fill price $0.50 is below your worst-price limit $0.55
Polymarket migration: This is identical to how Polymarket’s price field works. Your existing slippage logic transfers directly to PolySimulator — and vice versa when you migrate to live trading.

Price Is Required

Market orders must include a price field. Submitting a market order without price returns a 400 PRICE_REQUIRED error:
{
  "error": "PRICE_REQUIRED",
  "message": "Market orders require a 'price' field as a worst-price limit..."
}
This matches Polymarket’s design: there are no “blind” market orders. You always control the worst price you’ll accept.

Time in Force

Market orders default to FOK (Fill-or-Kill), matching Polymarket. You can also use FAK (Fill-and-Kill), Polymarket’s term for IOC.
ValueBehaviorPolymarket Equivalent
FOKAll-or-nothing — fill entirely or cancel (default for market orders)FOK
FAKFill available quantity, cancel remainderFAK
IOCSame as FAK (PolySimulator alias)FAK
GTCOverridden to FOK for market orders
{
  "market_id": "0xabc...",
  "side": "BUY",
  "outcome": "Yes",
  "quantity": "10",
  "order_type": "market",
  "price": "0.68",
  "time_in_force": "FAK"
}
If you omit time_in_force on a market order, it defaults to FOK. If you explicitly set GTC, it is overridden to FOK — market orders never persist in the book.

Execution Model

Market orders fill at the best available price — BUY at the best ask, SELL at the best bid — matching Polymarket’s execution model. The fill price resolution waterfall:
  1. Best bid/ask from the CLOB order book (most realistic)
  2. Cached CLOB midpoint from Redis (sub-ms, HFT fast-path)
  3. Gamma API price (fallback for cache misses)

Fill Diagnostics

Every market order response includes transparency metadata:
{
  "order_id": 42,
  "status": "FILLED",
  "price": "0.65",
  "price_source": "clob_book",
  "slippage_bps": 461
}
The slippage_bps field is informational only — it shows how far the fill price deviated from the cached mid-price, in basis points. It does not affect order execution. Your price (worst-price limit) is the only protection mechanism.

Price Sources

SourceDescriptionReliability
clob_bookFull order book walk from CLOB APIHighest — real depth
clob_midpointCLOB mid-price (fast-path)High
gamma_apiGamma API price feedMedium — may be delayed
gamma_poller:best_askBest ask from background pollerHigh — refreshed every 30s
gamma_poller:best_bidBest bid from background pollerHigh — refreshed every 30s
redis_cacheCached price from background pollerLower — up to 45s stale
Monitor price_source in your bot logs. If you see frequent redis_cache fills, the CLOB API may be experiencing issues. Consider pausing trading during degraded price quality.

Recommendations by Strategy

StrategyApproach
Scalping / HFTprice = best ask + $0.01 (tight limit, minimal overpay)
Swing tradingprice = best ask + $0.03 (moderate buffer)
Bulk accumulationprice = best ask + $0.05 (wider buffer for fill certainty)
Illiquid marketsUse limit orders (GTC) for price certainty
For illiquid markets with wide spreads, consider limit orders instead of market orders. Limits give you price certainty at the cost of fill uncertainty.

Comparison: PolySimulator vs Polymarket

FeaturePolymarketPolySimulator
Slippage protectionprice field (worst-price limit)price field (identical)
Price required on market ordersYesYes
Default time-in-force (market)FOKFOK
Execution modelBUY at best ask, SELL at best bidBUY at best ask, SELL at best bid
Price improvementYes — fill at best availableYes — fill at best available
Order typesFOK, FAK, GTC, GTDFOK, FAK, IOC, GTC
FeesTaker fees on some marketsZero (paper trading)

Next Steps