# Polymarket Historical Backtest API

> Polymarket Historical Backtest API is a paid API for AI agents from aiworker.duckdns.org, paid per call via x402, $0.25/call, status unknown (last checked 2026-09-13).

Backtests fixed trading rules (favorite_hold or longshot_hold) against resolved Polymarket prediction markets and returns statistical performance metrics

## Facts

- Endpoint: POST https://aiworker.duckdns.org/v1/polymarket/backtest
- Price: $0.25/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-13
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/polymarket-historical-backtest-api-93be545c
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_rAQzwkTw5hrK6I1ZLC73R

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability polymarket-historical-backtest-api-93be545c -d '<json body>'
```

Example prompt: Run a Polymarket backtest using the favorite_hold rule on politics markets from 2024-01-01 to 2025-06-30, with an entry threshold of 0.85 and a minimum volume of $5,000, and show me the hit rate, mean return, and calibration breakdown.

## When to prefer this

Choose this endpoint when you need reproducible, rules-based historical performance statistics on Polymarket resolved markets — especially for evaluating favorite-bias or longshot-bias strategies with configurable thresholds, date windows, and category filters. Prefer it over generic financial backtesting tools when the specific asset class is Polymarket prediction market contracts and you need calibration-level output (Brier score, implied vs realized probability buckets).

## Known failure modes

- Invalid date format (must match YYYY-MM-DD pattern)
- Category string not found or has fewer than 200 resolved markets in the store
- Threshold out of range (must be 0.55–0.99 for favorite_hold, 0.01–0.45 for longshot_hold)
- min_volume_usd below minimum of $1,000
- Payment not included or insufficient (x402 payment required at $0.25 USDC per call)
- Date range too narrow to produce meaningful results
- Server-side data store not yet updated to requested date range

## How this service works

Deterministic-first data for agents, paid per call in USDC over x402 v2: DeFi yields, Base token and wallet cards, Polymarket odds and backtests, news, fact checks, cited briefs. 20 routes, $0.005-$1

## Output

A JSON object containing: overall performance metrics (hit_rate, mean_return, Brier score, max_drawdown, avg_days_held, median_return), per-year breakdown of n/hit_rate/mean_return, calibration buckets comparing implied vs realized probability, a sample of individual trades, universe stats (candidates, matched, excluded counts), window parameters, caveats about survivorship bias, attribution to Polymarket data sources, and a disclaimer that results are historical replay not predictions.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "required": [
  "input"
 ],
 "properties": {
  "input": {
   "type": "object",
   "required": [
    "type",
    "method",
    "bodyType",
    "body"
   ],
   "properties": {
    "body": {
     "oneOf": [
      {
       "type": "object",
       "required": [
        "rule"
       ],
       "properties": {
        "to": {
         "type": "string",
         "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
         "description": "last resolution day, inclusive UTC (default: the store's data cut-off)"
        },
        "from": {
         "type": "string",
         "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
         "description": "first resolution day, inclusive UTC (default: three years before `to`)"
        },
        "rule": {
         "const": "favorite_hold",
         "description": "Fixed to \"favorite_hold\" in this branch of the schema."
        },
        "category": {
         "type": "string",
         "default": "all",
         "pattern": "^[a-z0-9][a-z0-9-]{0,63}$",
         "description": "\"all\" or a Polymarket event tag with at least 200 resolved markets in the store (see the categories list)"
        },
        "threshold": {
         "type": "number",
         "default": 0.8,
         "maximum": 0.99,
         "minimum": 0.55,
         "description": "buy the side priced at or above this on its first such day"
        },
        "min_volume_usd": {
         "type": "number",
         "default": 1000,
         "maximum": 10000000,
         "minimum": 1000,
         "description": "markets below this lifetime volume are excluded (a survivorship filter, stated in caveats)"
        }
       },
       "description": "The favorite_hold rule and its parameter.",
       "additionalProperties": false
      },
      {
       "type": "object",
       "required": [
        "rule"
       ],
       "properties": {
        "to": {
         "type": "string",
         "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
         "description": "last resolution day, inclusive UTC (default: the store's data cut-off)"
        },
        "from": {
         "type": "string",
         "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
         "description": "first resolution day, inclusive UTC (default: three years before `to`)"
        },
        "rule": {
         "const": "longshot_hold",
         "description": "Fixed to \"longshot_hold\" in this branch of the schema."
        },
        "category": {
         "type": "stri
… (truncated)
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "rule": "favorite_hold",
  "method": "On the first entry-eligible day (before the market resolved, closed or ended) whose YES close is at or above the threshold, buy YES at that close; …",
  "sample": [
   {
    "side": "yes",
    "slug": "will-donald-trump-win-the-2024-us-presidential-election",
    "return": 0.25,
    "outcome": "yes",
    "question": "Will Donald Trump win the 2024 US Presidential Election?",
    "entry_day": "2024-10-31",
    "entry_price": 0.8,
    "window_date_field": "resolved_at"
   }
  ],
  "window": {
   "to": "2025-12-31",
   "from": "2024-01-01"
  },
  "by_year": [
   {
    "n": 803,
    "year": 2024,
    "hit_rate": 0.9028,
    "mean_return": 0.0201
   },
   {
    "n": 507,
    "year": 2025,
    "hit_rate": 0.9053,
    "mean_return": 0.0242
   }
  ],
  "caveats": [
   "Survivorship: markets are selected by their lifetime volume as of the store build, which is not knowable on the entry day.",
   "…"
  ],
  "results": {
   "hit_rate": 0.9038,
   "brier_score": 0.0791,
   "mean_return": 0.0217,
   "max_drawdown": 0.0412,
   "avg_days_held": 23.4,
   "median_return": 0.1111,
   "avg_entry_price": 0.8731
  },
  "category": "politics",
  "universe": {
   "capped": false,
   "matched": 1310,
   "excluded": {
    "thin": 20,
    "short": 11,
    "volume": 96,
    "price_floor": 3
   },
   "candidates": 1842,
   "not_triggered": 402,
   "window_date_fallbacks": 9
  },
  "disclaimer": "A replay of a fixed, published rule over resolved markets; history, not a prediction, not advice.",
  "generation": 1,
  "parameters": {
   "threshold": 0.8,
   "min_volume_usd": 1000
  },
  "attribution": "Data: Polymarket public APIs (Gamma, CLOB), attributed; SII-WANGZJ/Polymarket_data (MIT) for on-chain fills before 2026-07-21; derived figures only, no feed.",
  "calibration": [
   {
    "n": 512,
    "bucket": "0.80-0.85",
    "implied": 0.8231,
    "realized": 0.8613,
    "mean_return": 0.0465
   },
   {
    "n": 431,
    "bucket": "0.85-0.90",
    "implied": 0.8702,
    "realized": 0.9026,
    "mean_return": 0.0373
   }
  ],
  "data_cutoff": "2026-09-09",
  "generated_at": "2026-09-10T12:00:00.000Z"
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/polymarket-historical-backtest-api-93be545c/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from aiworker.duckdns.org](https://www.zero.xyz/host/aiworker.duckdns.org/llms.txt)
