Meta description:** Explore how a Polymarket TWAP spike arbitrage bot detects temporary price dislocations, tests execution costs, and filters false trading signals.
A cryptocurrency price spikes sharply. A short-window time-weighted average price (TWAP) begins moving upward, but a related prediction-market contract appears slow to respond.
At first glance, this looks like an arbitrage opportunity.
The problem is that a price spike, a delayed market reaction, and a genuinely mispriced contract are three different things.
A Polymarket TWAP spike arbitrage bot must distinguish between them before committing capital.
The central question is simple: Can a temporary difference between a reference-price signal and a prediction-market price be converted into a positive expected return after execution costs?
About the Author
Soulcrancerdev specializes in the engineering and quantitative research behind automated prediction-market trading.
GitHub: https://github.com/thesoulcrancerdev/poly-trading-strategies
X: https://x.com/soulcrancerdev
Community: https://t.me/+SxEC7bVXYyphNzI5
Telegram: https://t.me/soulcrancerdev
Gmail: misssilverbeauty0927@gmail.com
YouTube: https://youtube.com/@soulcrancerdev
Why a TWAP spike is not automatically arbitrage
TWAP measures the average price of an asset over a defined period, weighting observations by elapsed time rather than trading volume.
For regularly spaced observations, a simplified calculation is:
TWAP = sum(reference_prices) / number_of_observations Consider a hypothetical BTC price sequence:
| Observation | BTC price |
|---|---|
| 1 | $95,000 |
| 2 | $95,020 |
| 3 | $95,040 |
| 4 | $95,400 |
| 5 | $95,420 |
The five-observation average is $95,176.
A sudden price increase has pushed the average higher, but this does not establish that a Polymarket YES token is underpriced.
A binary contract represents the probability of a specified outcome, not the underlying cryptocurrency's dollar price.
A BTC price spike may increase the probability of a YES outcome, but the size of that change depends on the contract's threshold, remaining time, volatility, and resolution rules.
A useful signal must therefore connect the reference-price movement to a probability estimate.
The dislocation framework
I would separate the research problem into five stages:
Reference Price Spike | v TWAP and Volatility Update | v Outcome Probability Estimate | v Polymarket Executable Price | v Net Expected Edge Suppose a calibrated model estimates a 64% probability that a YES contract will resolve successfully.
The best executable ask is $0.60.
For a binary contract paying $1 if YES wins and $0 otherwise:
gross_edge = estimated_probability - ask_price gross_edge = 0.64 - 0.60 gross_edge = 0.04 This hypothetical four-cent expected advantage is not risk-free arbitrage. It is a model-dependent trading opportunity.
If expected costs and a risk allowance total $0.015 per share:
net_edge = 0.04 - 0.015 net_edge = 0.025 The remaining 2.5 cents are an estimated expected edge, not a guaranteed return.
What the order book can hide
A bot may detect a favorable price but fail to execute at that price.
The displayed ask might contain only a small number of shares. Buying more can move execution into higher price levels.
Other traders may also react to the same reference-price spike, causing the apparent dislocation to disappear.
This creates three distinct risks: stale quotes, insufficient executable liquidity, and adverse selection.
For that reason, the strategy should evaluate the cost of filling its intended order size rather than relying only on the best ask.
A small Python experiment
The following standalone experiment uses synthetic observations to identify TWAP spikes and compare hypothetical model probabilities with executable prices.
from collections import dequeprices = [ 95000, 95020, 95040, 95400, 95420, 95410]window = deque(maxlen=3)previous_twap = Nonefor price in prices: window.append(price) if len(window) < 3: continue twap = sum(window) / len(window) if previous_twap is not None: change = twap / previous_twap - 1 if change > 0.001: print( f"TWAP spike detected: " f"{change:.3%}" ) previous_twap = twapestimated_probability = 0.64executable_ask = 0.60estimated_cost = 0.015net_edge = ( estimated_probability - executable_ask The spike threshold and probability estimate are illustrative. The example does not derive probability from the TWAP series, and it does not demonstrate a profitable strategy.
A proper experiment would estimate outcome probabilities using historical data, then evaluate those estimates against subsequent outcomes.
What most traders get wrong
A fast price move does not guarantee a delayed prediction-market response. Market participants may already have incorporated the information.
A positive theoretical edge is not necessarily executable. Available depth and slippage can eliminate the advantage.
A short TWAP window is not universally better. Short windows respond quickly but can amplify noise; longer windows smooth fluctuations but introduce lag.
A correct directional prediction is not enough. The contract price must offer sufficient value relative to the estimated probability.
Engineering the strategy for production
A production system needs synchronized reference-price data, Polymarket order-book observations, a probability model, execution controls, and position reconciliation.
Record event timestamps and local receipt times separately. Preserve raw market data so signals can be replayed and audited.
Historical testing must avoid look-ahead bias and account for data latency, spread changes, partial fills, and fees.
The bot should also stop evaluating new trades when reference data becomes stale or the local order book cannot be trusted.
Advanced observations
One subtle problem is that the reference-price spike and the prediction-market response may occur on different clocks. Poor timestamp alignment can manufacture apparent opportunities.
Another is that signal strength depends on distance from the outcome threshold. The same BTC price movement can have very different probability implications across contracts.
Finally, a strategy that performs well during volatile periods may fail when volatility, liquidity, or participant behavior changes.
These are reasons to test the model across multiple market regimes rather than optimize it around a handful of attractive spikes.
Conclusion
The interesting part of a Polymarket TWAP spike strategy is not detecting the spike. It is determining whether the spike changes the probability of a contract's outcome more than the executable market price already reflects.
The next engineering step is to build a timestamped dataset connecting reference prices, contract specifications, order-book depth, and eventual outcomes.
Only then can the apparent dislocation be evaluated as a repeatable trading hypothesis.
Trading-risk disclaimer: All numerical examples are hypothetical. This strategy is not guaranteed arbitrage. Trading involves execution, liquidity, fees, model error, volatility, and market-resolution risks. Past observations do not guarantee future results.

