> ## Documentation Index
> Fetch the complete documentation index at: https://docs.polysimulator.com/llms.txt
> Use this file to discover all available pages before exploring further.

# How PolySimulator matches Polymarket

> The data, timing, fee and order models behind simulated trading, and where they differ from the venue.

# How PolySimulator matches Polymarket

PolySimulator uses Polymarket market data to simulate orders in a paper account.
It never sends your orders to Polymarket. **Simulated fills are measured against
the venue**, with differences in timing, available liquidity and accounting.
API compatibility alone does not establish execution fidelity.

> [!NOTE]
>
> **Draft, checked 2026-11-13.** This page distinguishes implemented behavior
> from deployment settings and planned work. Public docs publish from `staging`,
> while production can run an older revision. The optional taker hold described
> below arrives with the 24.11 release and is not live before then.

## Data source and freshness

Market identity and metadata come from Polymarket's Gamma feed. Prices and
order books use its CLOB WebSocket and REST feeds. The implementation includes
a Rust ingestion service for selected market scopes, alongside Python ingestion.
Having that service in the source does not prove that it owns every market's
live feed.

The Rust implementation can reconstruct books from WebSocket snapshots and
deltas and compare them with REST book snapshots. REST verification can retain
an equivalent streamed book or trigger repair when depth diverges. Reconnects
and repeated observations must not be mistaken for new venue activity.

Three different clocks matter:

| Observation | What it tells you | What it does not establish |
| - | - | - |
| Venue event timestamp | Time reported by the upstream event | When PolySimulator or your client received it |
| Quote timestamp / reported age | Freshness of the selected cached observation | Network transit or latency for every ingestion stage |
| Client request or stream receive time | When your own application saw the response | When the venue could have executed your order |

**Internal pipeline stages** include socket receipt, frame queuing, book
reconstruction, REST verification, cache publication and API/feed delivery.
Their timings require internal instrumentation. A fast cache lookup measures
one stage; it is not a venue-to-client delay measurement. This draft publishes
no internal pipeline latency percentile.

### A small public measurement, with its limits

On staging, 12 anonymous `GET /v1/price?token_id=…&side=BUY` requests from one
sandbox client during **2026-11-13 23:15:57–23:16:05 UTC** returned:

| Metric | p50 | p95 | Samples |
| - | -: | -: | -: |
| Client HTTP round trip, including connection setup and body decoding | 283.876 ms | 460.974 ms | 12 |
| Response's reported `age_ms` | 37 ms | 840 ms | 12 |

This is a small observation, not an SLA or a venue event propagation benchmark.
The client's geographic location was not established. Each request opened a
new connection; requests were separated by a 500 ms pause. Percentiles use
nearest rank. The token was
`20006732765674855733524007935991362439352594042415161039767275461950712817548`.
Results will change with time, location and market activity.

To repeat the method, set `POLYSIM_BASE_URL` to the host you want to measure
and `TOKEN_ID` to a currently available outcome token. The example performs
public reads only:

```python theme={null}
import json
import math
import os
import time
import urllib.request

base = os.environ["POLYSIM_BASE_URL"].rstrip("/")
token = os.environ["TOKEN_ID"]
url = f"{base}/v1/price?token_id={token}&side=BUY"
rtt, ages = [], []
for _ in range(12):
    start = time.perf_counter()
    request = urllib.request.Request(
        url, headers={"User-Agent": "PolySimulator-Docs-Audit/1.0"}
    )
    with urllib.request.urlopen(request, timeout=10) as response:
        data = json.load(response)
    rtt.append((time.perf_counter() - start) * 1000)
    if isinstance(data.get("age_ms"), (int, float)):
        ages.append(data["age_ms"])
    time.sleep(0.5)

for name, values in [("http_ms", rtt), ("reported_age_ms", ages)]:
    ordered = sorted(values)
    if ordered:
        print(name, "n=", len(ordered), {
            p: ordered[math.ceil(p * len(ordered)) - 1] for p in (0.5, 0.95)
        })
```

To measure propagation instead, record the **same token and identifiable
venue update** on the venue stream and PolySimulator's stream, timestamp both
arrivals with the same client clock, and report the difference. Preserve raw
frames, reconnect gaps, unmatched updates, sample count, window and host
revision. Comparing two unrelated book reads or subtracting unsynchronized
host clocks does not provide that measurement. Our public feeds can coalesce
updates, so missing event correspondence must be reported rather than treated
as zero delay.

## How an order becomes eligible to fill

**Immediate orders:** native market orders default to FAK/IOC. They fill the
available quantity within the price constraint and cancel the remainder.
FOK requests require the full quantity or fail. Price resolution and depth
requirements depend on the execution path and active safety settings; legacy
market-price paths can use fallback quotes when a usable book is unavailable.
Read `price_source`, fee and filled quantity rather than assuming a book walk.

**Fill on placement:** a marketable GTC/GTD limit can fill in its placement
request when that feature is enabled and the book, deadline and venue checks
pass. It shares fill primitives with the background matcher. A skipped
placement fill can leave an order pending for a later cycle.

**Resting orders:** the background matcher repeatedly checks pending orders.
A BUY needs an executable ask at or below its limit; a SELL needs an executable
bid at or above it. A last-trade price touching the limit is not sufficient.
Depth, freshness and market lifecycle checks can prevent a fill. The code's
default sleep between cycles is **1 second**, an internal configuration default;
cycle work and runtime overrides determine the observed interval.

**Event-driven resting-order matching is planned.** The audited implementation
uses the cycle above; it does not promise a fill after each incoming venue event.
There is no model of your place behind real venue orders at a price level.

For depth walks, BUY consumes asks from lowest upward and SELL consumes bids
from highest downward. Binary-market pricing can also use complementary depth
at `1 − price`. Simulated consumed depth can be withheld across orders for a
bounded refresh/window period. This does not change Polymarket's real book or
simulate how other traders react to your order.

## Taker delay (from the 24.11 release)

> [!NOTE]
>
> **Not live yet.** The taker delay ships with the PolySimulator 2.0 release on
> 24 November 2026. Until that release, taker orders on PolySimulator are **not**
> held before matching. This section describes the behaviour that release adds.

From the 24.11 release, PolySimulator includes an **optional taker hold** that
the operator can switch on. It is off by default. When it is on, its default
duration is **150 ms**, and the operator can change it. This is a configured
setting, not a measured latency guarantee.

When enabled, it checks the venue market-info `itode` boolean to decide which
markets need the hold. Positive and negative results are cached. If lookup
cannot establish a result, the implementation falls back to recognizing fast
5-minute and 15-minute crypto Up/Down markets; it does not delay every market.

The hold applies to eligible taker requests, including marketable limits, before
pricing and balance reservation. Resting makers are not deliberately delayed.
The code checks the remaining request budget and can refuse with `503 SERVER_BUSY`
rather than shorten the hold. The hold does **not** make an order response use
Polymarket's `delayed` status.

If you measure order-to-fill time, measure it separately from the configured
hold, which is only one part of that time.

## Fees

Each market's fee follows its Gamma `feesEnabled` flag and `feeSchedule`
(`shares × rate × [price × (1 − price)]^exponent`), with five-decimal fee
calculation and cent-precision balance settlement. Category rates apply only
as a fallback when that metadata is unavailable. Maker fills
pay zero; a recorded marketable-at-placement verdict receives taker treatment.
An unknown verdict can use a legacy age-based classification fallback.

The fallback category rates are **measured against** Polymarket's
[published fee table](https://docs.polymarket.com/trading/fees), not assumed
equivalent; they can diverge when the venue changes its table. The rates,
unknown-category fallback and the formula are listed on
[Trading Fees](https://docs.polysimulator.com/trading/fees.md). The simulator does not pay maker rebates
(`/v1/fee-rate` reports the market's `rebate_rate`). A marketable GTC/GTD
remainder retains taker treatment on later fills.
Use the actual `fee` on each fill to reconcile simulated P\&L.

## Order types and API compatibility

| Surface | Order policy |
| - | - |
| Native `POST /v1/orders` | Limit: GTC by default; market: FAK/IOC by default; FOK; GTD limits with expiration |
| PM-shaped `POST /v1/order` | GTC, FOK, FAK, GTD; fixed-point maker/taker amounts |
| Convenience `POST /v1/clob/order` | GTC, FOK, GTD; IOC/FAK unsupported here |

With the default order semantics enabled, GTD expires and post-only GTC/GTD
rejects if marketable. Deployments using legacy semantics differ; consult
[Placing Orders](https://docs.polysimulator.com/trading/placing-orders.md) and the
[raw HTTP guide](https://docs.polysimulator.com/concepts/pm-raw-http.md). API keys, response status enums and
SDK support also differ by surface. None of these endpoints sends a signed
order to the venue or settles on-chain.

## Differences to include in strategy evaluation

| Difference | Consequence and reason |
| - | - |
| No venue queue position | A simulated resting fill cannot establish that your real order would have reached the front of the queue. The simulator cannot observe that position. |
| Periodic resting-order checks | Short-lived venue liquidity can appear and disappear between cycles. Event-driven matching remains planned. |
| Scope-specific ingestion, caches and fallback quotes | A fast response can carry older or less detailed data. Check timestamps, depth and `price_source`. |
| Local depth depletion, no external impact | Repeated orders can consume simulated depth, but the venue and other traders do not respond to paper orders. |
| Optional taker hold (from the 24.11 release) | Not live before 24.11. Once released it is off by default, and switching it on does not make end-to-end execution timing equal to the venue. |
| Fallback fee rates, rebates and remainder classification | Category fallback rates (used only without Gamma fee metadata), maker rebates and partial-fill treatment can differ from the venue. |
| Paper ledger and recovery paths | No gas or blockchain finality; a documented emergency exit at entry price is a recovery operation, not evidence of venue liquidity. |
| Curated market universe and historical archive | A venue market or interval may be unavailable here; archive coverage and fill-model assumptions must be checked separately. |

For the versioned list of models, defaults, measured delays and planned
changes, see the [Execution contract](https://docs.polysimulator.com/concepts/execution-contract.md).
Use [Honest Limits](https://docs.polysimulator.com/concepts/honest-limits.md) for operational boundaries and
[Simulation API](https://docs.polysimulator.com/simulation.md) for historical fill models. Validate performance
against observed venue data before interpreting simulated execution as evidence
about a strategy on Polymarket.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.