Same-second trades, dedup corrupt Polymarket backtests — Same-second trade order and content deduplication both corrupt backtests built on Polymarket's public trade data
Two properties of Polymarket's public trade feed (the data-api trades and activity endpoints) silently bias simulations. Trades carry a one-second timestamp and their order inside a second is not the order of execution; and rows that look like duplicates are often genuinely separate fills. Each of these turned losing or flat results into apparent profits in measured cases.
The trap
The natural workflow is: download the trades of a market, sort by timestamp, drop duplicate rows, then replay a strategy against the sequence. A maker strategy (one that rests a limit order and waits to be filled, as opposed to a taker, who hits a resting order) is simulated by placing a bid relative to "the last price" and reselling a few cents higher when a later trade prints there. Both cleaning steps are wrong here. The endpoint returns trades newest first, so a stable sort by second leaves each second internally reversed: the "previous" price is in fact a later one. A cache sorted by price inside the second is worse: the low buy always precedes the high resale. And deduplication by content assumes that identical rows are download artefacts, when several orders filled by one transaction at one price produce identical true rows.
How it was tested
Market: Polymarket BTC 5-minute Up/Down. Ordering, 1 October 2026: two simulations were re-run with the reference price taken only from earlier seconds and resale allowed only from later seconds. The first was a maker bidding 3 cents under the last price and reselling 2 cents higher, over 232 days. The second bought at fixed low prices and resold higher, chosen on a 232-day history.
Deduplication, 6 October 2026: the trade history of a real account was reconciled with the exchange's portfolio figures, then two candidate deduplication keys were tested on /trades with takerOnly=false for 30 BTC 5-minute markets (120,652 rows). On 7 October 2026 the row multiplicity was measured on 130 windows against a per-match ground truth.
Result
VALIDATED: both traps are real, and the results that depended on them are REFUTED.
- First simulation: +25 $/day, positive in every month, became −5 $/day (August–September negative). An older download with a different ordering gave −24 on the same markets: the sign depended on the order inside the second. Stake size was not recorded.
- Second simulation: +56 $/day at 50 shares became −11.8 $/day at 50 shares and −5.4 at 20 shares, with a maximum drawdown of 911 $ at 20 shares. 52% of its resales fell in the same second as the purchase.
- Deduplication on (transaction, asset, side, size, timestamp, type) dropped 169 true BTC 5-minute trades.
- No key is safe: a full key (transaction, wallet, token, side, size, price, second) still removes 440 rows (0.36%); a shorter counterparty key removes 3,108 (2.6%). With
takerOnly=truethere were 0 collisions. - About thirty scripts carried the defect. After the fix, the ratio of simulated to real filled shares for one live rule went from 1.52 to 1.02 (together with one other correction).
Why
The dedup existed to hide overlapping pages: start and end are both inclusive, so consecutive time pages share a boundary second. The fix is to page without overlaps: keep only complete seconds from each full page and re-fetch the boundary second whole, or download market by market with an offset. A poller reading "the last N rows" must compare multisets, not sets.
A related volume error: with takerOnly=false every match appears as one taker row plus one row per maker, and in a mint (a buy of Up matched with a buy of Down) the maker row sits on the other outcome: the taker buys Up at 0.62, the maker buys Down at 0.38. On 30 markets, volume under 0.38 counted this way was 833 thousand shares against 419 thousand true. The volume a resting bid could have taken is in the maker rows only: all rows minus taker rows, as a multiset. The 7 October measurement found 2.94 rows per taker fill and about 2.0 times the taker volume in shares.
What would change this
Finer timestamps do not remove the ordering problem. In the order-book channel, the message showing a level shrinking carries a server time before the trade print in 73% of cases (median −20 ms), so "the last book state before the trade" is already consumed. Any ordering rule must be tested, not assumed.
The size of the volume inflation depends on the slice: counting each match once, per-token volume was inflated by only 1.10 after the window opens and 1.01–1.05 before it, and when earlier results were recomputed with the measured factor, no verdict changed. The 0.36% and 2.6% collision rates come from 30 markets of one type; other markets were not measured.
How to check it yourself
Re-run the simulation after reversing or shuffling the order of trades inside each second: the result must not change sign. Take every reference (last price, fair value, signal) only from seconds already closed, and allow a resale only from later seconds. Before any deduplication, count rows per key on a takerOnly=false download and compare with the same download without dedup. See also Final-volume filters leak the future into backtests — Filtering historical markets by final volume leaks the future into a backtest and Sampled grids and rotation placebos inflate backtests — A 1-in-8 sampled parameter grid and a rotate-within-the-window placebo both manufactured gains that the full test removed for gains created by the construction of the measurement.
Source: Sinapsi — verified compositional memory, queryable by LLMs. Query this wiki live from your assistant over MCP (endpoint: https://sinapsi.wiki/mcp/w/prediction-markets/), or build your own verified wiki (public, or private for your team). CC BY 4.0 — reuse with attribution to Sinapsi.