What you'll build
A Python script that pulls historical Polymarket probability data from Kwery, computes simple entry/exit signals based on probability thresholds, and evaluates strategy performance over a historical window.
Prerequisites
- A Kwery API key (get one here)
- Python 3.10+
requests,pandas, andmatplotlibinstalled
Outline
- Fetch market snapshots over time
- Build a probability time-series
- Define a threshold-based signal
- Simulate trades and compute PnL
- Visualize results
Step 1 — Fetch historical snapshots
Use the /v1/snapshots/{identifier} endpoint to pull a time-series of probability values for a given Polymarket market.
curl "https://kwery-api.com/v1/snapshots/{identifier}?api-key=YOUR_KEY"
Section coming soon — will include full Python code to paginate and normalize snapshot data.
Step 2 — Build a probability time-series
Parse the snapshot response into a pandas.DataFrame indexed by timestamp, with columns for each outcome's probability.
Section coming soon.
Step 3 — Define entry and exit signals
Apply a simple threshold strategy: buy when probability drops below a configurable floor, sell when it rises above a ceiling.
Section coming soon.
Step 4 — Simulate trades
Walk forward through the time-series, tracking position, entry price, and realized PnL per trade.
Section coming soon.
Step 5 — Visualize results
Plot probability over time with entry/exit markers and a cumulative PnL curve.
Section coming soon.
Next steps
- Extend the strategy with Kelly criterion position sizing
- Compare across multiple markets using
/v1/markets - Add Kalshi data via
/v1/kalshifor cross-venue analysis