DEV Community

Cover image for How Polymarket settles its 5-minute Bitcoin rounds, recomputed in Python
ekocam
ekocam

Posted on Originally published at orcalayer.com

How Polymarket settles its 5-minute Bitcoin rounds, recomputed in Python

Every five minutes Polymarket opens a new market: will Bitcoin be higher at the end of this round than at its start? That is 288 rounds a day, plus the same thing every 15 minutes, hourly and daily, for Bitcoin, Ethereum, Solana and XRP.

We built a live page for these rounds, and the first thing we had to get right was the settlement math. This post walks through it in Python: how a round is decided, how to project the result while the round is still running, and one bit of arithmetic that explains why most people trading these rounds lose. The numbers come from our writeup on 9,197 five-minute rounds.

A round is decided by two averages, not two ticks

Both sides of the comparison are 60-second averages of the Chainlink BTC/USD price:

  • Price to beat: the average over the 60 seconds just before the round starts. It is also the previous round's final.
  • Final price: the same 60-second average over the last minute of the round.
  • Result: Up if the final is at or above the price to beat, so a tie goes to Up. Otherwise Down.

Assume you have one price per second, as a dict from a Unix second to a price:

from statistics import fmean

def window_avg(prices: dict[int, float], end_ts: int, seconds: int = 60) -> float:
    """Average of the per-second prices in [end_ts - seconds, end_ts)."""
    window = [prices[t] for t in range(end_ts - seconds, end_ts) if t in prices]
    if len(window) < seconds:
        raise ValueError(f"only {len(window)} of {seconds} seconds available")
    return fmean(window)

def round_result(prices: dict[int, float], start_ts: int, end_ts: int) -> str:
    price_to_beat = window_avg(prices, start_ts)   # the minute before the start
    final = window_avg(prices, end_ts)             # the last minute of the round
    return "Up" if final >= price_to_beat else "Down"
Enter fullscreen mode Exit fullscreen mode

The ValueError is deliberate. If your feed has gaps, silently averaging fewer seconds gives you a different number from the one the market settles on. Fail loudly and fill the gap first.

We compute the price to beat, the final and the result ourselves and compare them with Polymarket's own resolution afterwards. Since 17 November that is 2,069 rounds across all series, with the same result every time.

Why a last-second spike matters less than the chart suggests

The final is an average of 60 seconds, so one second contributes 1/60 of it. A $60 spike in the last second moves the final by $1. It moves the chart by $60.

That cuts the other way too: the round is not settled until the last second is over, because every second still counts.

Projecting the final while the round is running

During the last minute you already know part of the average. A simple projection fills the seconds you have not seen yet with the latest price:

def projected_final(prices: dict[int, float], end_ts: int, now_ts: int, seconds: int = 60) -> float:
    start = end_ts - seconds
    seen = [prices[t] for t in range(start, min(now_ts, end_ts)) if t in prices]
    if not seen:
        return prices[max(t for t in prices if t < now_ts)]   # before the last minute: latest price
    remaining = seconds - len(seen)
    return (sum(seen) + remaining * seen[-1]) / seconds
Enter fullscreen mode Exit fullscreen mode

With 50 seconds already in the window, only 10 of 60 are still unknown, so even a big move late in the round can only shift the projection by a sixth of its size.

How good does this get? Our projection, one second before the end, is within $1.47 of the final in 99% of rounds. That sounds tight until you look at how close the rounds are.

How close the rounds get

For the 871 Bitcoin 5-minute rounds since 17 November we have both averages to the cent:

Distance between final and price to beat Share of rounds
under $10 9.3%
under $25 23.9%
median distance $58.88

Almost one round in ten is decided by less than ten dollars on a ~$63,000 asset. About 1.6% of rounds end closer than the projection's own error one second before the end. Those really cannot be called until they close. Over 32 days Up won 48.6% of 9,197 rounds, a coin flip.

The arithmetic most traders skip

A share pays $1 if its side wins. Buy at price p and win with probability w, and your expected profit per share is:

def ev_per_share(entry: float, win_rate: float) -> float:
    return win_rate * (1 - entry) - (1 - win_rate) * entry   # simplifies to win_rate - entry

print(ev_per_share(0.64, 0.64))   # 0.0   -> break-even at 64c needs a 64% win rate
print(ev_per_share(0.99, 0.99))   # 0.0   -> a 99% win rate at 99c is also just break-even
print(ev_per_share(0.40, 0.52))   # 0.12  -> 52% at 40c is far better than 79% at 85c (-0.06)
Enter fullscreen mode Exit fullscreen mode

Break-even win rate equals the entry price, before fees. That one line explains the wallet data. Of 22,827 wallets that played 20+ Up/Down rounds in 30 days (market-making bots left out):

  • only 22.6% made money;
  • 45% won 55% or more of their rounds;
  • 73% of those high-win-rate wallets lost money. Their median entry was 64¢, against about 33¢ for everyone else.

The extreme case: a wallet that won 99.0% of 2,940 rounds, at an average entry of 98.8¢, on $7.4M of volume, finished 30 days at -$3,664. Each win paid about a cent a share; each loss cost ninety-nine.

Takeaways if you build on these markets

  • Reproduce the settlement from the same Chainlink feed and reconcile it with the market's resolution. Do not trust a chart.
  • Treat missing seconds as an error, not as something to average around.
  • Score wallets by P&L per dollar traded and entry price, not win rate. In these markets win rate mostly tells you what price someone likes to pay.

You can watch the current round, the projection and every wallet entering it on the live page.


Originally published on orcalayer.com. OrcaLayer is an independent Polymarket analytics provider, not affiliated with Polymarket. Not a trading signal.

Top comments (0)