Guide
Exit rules for Polymarket backtests
Entries get the attention, but exits decide the distribution of returns. A take-profit truncates your winners; a hold-to-expiry leaves the outcome to settlement. The backtester lets you express each and see the difference.
What this guide covers
- Backtest AI exit types: take_profit, stop_loss, trailing_stop, time and hold_to_expiry
- hold_to_expiry defaults to true when no other exit is set
- The backtest report includes exit_reasons so you can see where each trade ended
- Short-window markets settle fast, so time exits and settlement exits often coincide
The five exit types
A take-profit closes once the position gains a target amount. A stop-loss closes once it loses a set amount. A trailing-stop follows the price up and closes on a pullback of a given size. A time exit closes after a fixed holding period. Hold-to-expiry carries the position to settlement, which is the natural default on markets that resolve in minutes.
Each encodes a different belief. Take-profit says 'bank the win before it reverses'; hold-to-expiry says 'the settlement price is my exit'. On a 5-minute market these can be nearly the same trade with very different fills.
| Type | Closes when |
|---|---|
| take_profit | Gain reaches a target |
| stop_loss | Loss reaches a limit |
| trailing_stop | Price pulls back from a peak |
| time | A fixed holding period elapses |
| hold_to_expiry | The market settles (default) |
Take-profit versus hold-to-expiry
On a market that settles in five minutes, a take-profit and hold-to-expiry often close at similar times, but they do not produce the same fills. A take-profit is a taker order against the book and pays the spread; settlement is free and pays nothing. So a take-profit must beat settlement by more than its execution cost to be worth using.
The report's exit_reasons breaks down how many trades ended each way, which makes this visible. If nearly every take-profit fires a second before settlement, you are paying the spread for almost no benefit.
Stops on short markets
A stop-loss on a 5-minute binary is a blunt tool. The contract moves between roughly zero and one, so a stop can fire on noise and lock in a loss that settlement would have reversed. On short markets, stops mostly convert benign mid-trade volatility into realized losses.
That is not an argument against stops everywhere - on longer horizons and larger positions they cap tail risk. It is an argument for measuring the effect per horizon rather than assuming a stop is always prudent. The backtester can show both variants side by side.
Reading exit_reasons
The report exposes exit_reasons, the count of trades that ended each way, alongside total_pnl and the equity curve. Read them together: a strategy that looks profitable but exits almost entirely on time may simply be riding settlement noise rather than demonstrating a signal.
Also compare the number of exits to the number of entries. A gap means trades were still open at the end of the sample, and those open positions are neither wins nor losses yet - excluding them from the win rate rather than counting them as losses.
Code examples
import requests
BASE = "https://api.polyorderbooks.com/v1"
HEADERS = {"X-API-Key": "your-key", "Content-Type": "application/json"}
# Compare a take-profit exit against hold-to-expiry.
tp = {"strategy": {"market": {"coin": "eth", "market_type": "5m"},
"side": "yes", "entry": [{"type": "reference", "change": 0.001}],
"exit": {"type": "take_profit", "value": 0.002}}}
hx = {"strategy": {"market": {"coin": "eth", "market_type": "5m"},
"side": "yes", "entry": [{"type": "reference", "change": 0.001}],
"exit": {"type": "hold_to_expiry"}}}
for plan in (tp, hx):
plan.update({"sampleSize": 50, "days": 5})
r = requests.post(f"{BASE}/ai/backtest", headers=HEADERS, json=plan)
r.raise_for_status()
rep = r.json()["report"]
print(plan["strategy"]["exit"]["type"], rep["exit_reasons"])Free tier
The Starter plan is free, includes order books, prices, and metrics at 250ms resolution, with 3 days of history, 60 requests/min, 1,000/day, 1 free AI backtest, and 3 strategy backtests. No credit card required.
Paid data windows from $19/mo extend history to 30–120 days at higher throughput. Backtest AI add-on is +$19/mo or standalone at $29/mo.
FAQ
What is the default exit?
hold_to_expiry, which carries the position to settlement. It defaults to true when no other exit is specified.
Should I use a stop-loss on 5-minute markets?
Usually not. On a binary that moves between 0 and 1, stops fire on noise and lock in losses settlement would have reversed. Measure the effect per horizon rather than assuming.
Take-profit or hold-to-expiry?
Compare them. A take-profit is a taker exit that pays the spread, so it must beat settlement by more than its execution cost to be worth using.
How do I know why trades closed?
The report includes exit_reasons, a count of trades ending each way, which you should read alongside total_pnl and the equity curve.