ResearchSkybitOpen app

How do I avoid duplicate prediction market orders after an API timeout?

By Skybit Research ยท Published
Sources verified Nov 11, 2026.

Treat a timeout as an unknown state. Record an internal attempt ID, query open orders and fills, and wait for a terminal state before replacing size. Retry only the unconfirmed remainder, never the original order. Kalshi and Polymarket differ on 429 guidance and batch admission, so keep venue-specific replay rules.

Treat a timeout as unknown, not failed

An HTTP timeout tells you only that your client did not receive a response; it does not prove the venue rejected the order. Freeze new entries for that market and strategy, then record the attempt as UNKNOWN with market, side, price, size, timestamp, credential, and any venue order ID. Separate two economic states: a resting order locks capital, while a fill creates outcome exposure. A partial fill is both, so reconcile quantity, not just order status.

Use authenticated order and trade streams as early evidence, not as the sole source. Polymarket's CLOB user channel follows authenticated order and trade updates for an account, and Kalshi serves fill and user_orders channels on separate lower-latency WebSocket hosts. Streams can disconnect or lag; if the stream is not healthy, fall back to authenticated REST reconciliation. Do not infer your own order state from public market data.

Sources: [1] [2]

Reconciliation sequence before any retry

Run a fixed sequence. First, stop new risk on the affected market. Second, fetch open orders and recent fills, matching on market, side, price, size, and time window. Third, if an order is open, cancel it and wait for a terminal confirmation. Fourth, compute confirmed filled versus confirmed remaining. Only then may you replace the unconfirmed remainder with a new attempt ID. Polymarket's L2-authenticated GET /data/orders retrieves open orders.

Handle throttling as a separate branch. Kalshi returns 429 without Retry-After or X-RateLimit headers and says there is no penalty or cooldown, so use exponential backoff and do not tighten the retry loop. Polymarket returns Retry-After when the request fits the tier's burst capacity; if the request costs more than burst, split it rather than retrying unchanged. A 429 is not proof that an earlier timed-out create failed.

Sources: [1] [3] [4]

Venue-specific replay rules

On Kalshi event contracts, an explicit shard write draws that shard's Write bucket, while auto-routed traffic draws every shard's Write bucket. Batch creates cost the same as individual calls and must fit the bucket at once or the whole batch is rejected. So do not convert a timed-out single order into a batch retry. Kalshi Perps use separate buckets, so event-contract replay rules do not carry over to perps.

On Polymarket international, a batch is admitted only if the bucket holds tokens for every entry; otherwise the entire request is rejected and no entries are processed. That admission rule does not tell you what happened to a batch that was admitted before a timeout. Cancel-all is also metered: it consumes one token then debits per successful cancellation, which can push some tiers' cancel balance negative. Verify Polymarket US separately.

Sources: [3] [4]

Worked ledger and failure cases

Hypothetical: send 100 YES at $0.42 on Kalshi, then the HTTP call times out. Reconciliation finds 30 filled and 70 resting. Cancel the 70 and confirm terminal; you now hold 30 YES, a $12.60 debit before fees, and no locked remainder. If the target is 100, place 70 with a new attempt ID. Blindly resending 100 could leave 130 filled if the second order is accepted.

Failure cases are stale streams, cancel timeouts, partial cancels, subaccount-scoped keys, and maintenance halts. Kalshi public order-book levels can lag your own orders and temporarily appear locked or crossed, so never use them as order-state proof. Resolution source is also not order-state evidence: Polymarket prediction markets use UMA, while up-down markets use Chainlink TWAP. If open-order and fill evidence conflict, halt replacement and escalate.

Sources: [2] [5]

Unknown-order-state reconciliation ledger
FieldHypothetical valueOperational use
Attempt IDK-17Internal key for one logical order; not a venue idempotency key.
Confirmed fill30 YES at $0.42Outcome exposure; $12.60 debit before fees.
Resting remainder70 YES at $0.42Locked capital $29.40; cancel and confirm terminal.
Replacement70 YES, attempt K-18Replace only the unconfirmed remainder, never the full 100.

Assumptions and scope

  • The venue exposes authenticated open-order and fill data; if not, halt and reconcile manually.
  • No client-supplied idempotency key is assumed; retries create new orders unless you have verified venue support.
  • Synthetic example ignores fees, rebates, queue position, and partial-cancel mechanics.
  • Scope is event contracts; Kalshi Perps and Polymarket US require separate verification.

Sources and verification

  1. Polymarket API surfaces
    Source checked Nov 11, 2026.
  2. Kalshi API changelog
    Source checked Nov 11, 2026.
  3. Kalshi API rate limits
    Source checked Nov 11, 2026.
  4. Polymarket trading rate limits
    Source checked Nov 11, 2026.
  5. Polymarket resolution mechanisms
    Source checked Nov 11, 2026.

Prepared by Skybit Research with AI assistance and automated source checks. Examples and assumptions are identified in the article. No human reviewer is implied. Check the exact contract and current venue documentation before applying a method.