{"uid":"cap_rAQzwkTw5hrK6I1ZLC73R","slug":"polymarket-historical-backtest-api-93be545c","name":"Polymarket Historical Backtest API","description":"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","url":"https://aiworker.duckdns.org/v1/polymarket/backtest","method":"POST","headers":{},"bodySchema":{"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":"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.1,"maximum":0.45,"minimum":0.01,"description":"buy the side priced at or below 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 longshot_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":"late_entry","description":"Fixed to \"late_entry\" 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)"},"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)"},"days_before_end":{"type":"integer","default":7,"maximum":60,"minimum":1,"description":"enter this many days before the market's end date (the last close in the 7 days before that day)"}},"description":"The late_entry 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":"momentum_1w","description":"Fixed to \"momentum_1w\" 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.1,"maximum":0.5,"minimum":0.02,"description":"buy in the direction of a 7-day move of at least this much"},"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 momentum_1w rule and its parameter.","additionalProperties":false}],"description":"Which rule to replay, with its one parameter, over which category and resolution-date window."},"type":{"type":"string","const":"http"},"method":{"enum":["POST"],"type":"string"},"bodyType":{"enum":["json","form-data","text"],"type":"string"}},"additionalProperties":false},"output":{"type":"object","required":["type"],"properties":{"type":{"type":"string"},"example":{"type":"object","properties":{"rule":{"enum":["favorite_hold","longshot_hold","late_entry","momentum_1w"],"type":"string"},"method":{"type":"string"},"sample":{"type":"array","items":{"type":"object","properties":{"side":{"enum":["yes","no"],"type":"string"},"slug":{"type":"string"},"return":{"type":"number"},"outcome":{"enum":["yes","no"],"type":"string"},"question":{"type":"string"},"entry_day":{"type":"string"},"entry_price":{"type":"number"},"window_date_field":{"enum":["resolved_at","closed_at","end_at"],"type":"string"}}}},"window":{"type":"object","properties":{"to":{"type":"string"},"from":{"type":"string"},"clamped_from":{"type":"boolean"}}},"by_year":{"type":"array","items":{"type":"object","properties":{"n":{"type":"integer"},"year":{"type":"integer"},"hit_rate":{"type":"number"},"mean_return":{"type":"number"}}}},"caveats":{"type":"array","items":{"type":"string"}},"results":{"type":"object","properties":{"note":{"type":"string"},"hit_rate":{"type":["number","null"]},"brier_score":{"type":["number","null"]},"mean_return":{"type":["number","null"]},"max_drawdown":{"type":["number","null"]},"avg_days_held":{"type":["number","null"]},"median_return":{"type":["number","null"]},"avg_entry_price":{"type":["number","null"]}}},"category":{"type":"string"},"universe":{"type":"object","properties":{"capped":{"type":"boolean"},"matched":{"type":"integer"},"excluded":{"type":"object","properties":{"thin":{"type":"integer"},"short":{"type":"integer"},"volume":{"type":"integer"},"price_floor":{"type":"integer"}}},"candidates":{"type":"integer"},"not_triggered":{"type":"integer"},"window_date_fallbacks":{"type":"integer"}}},"disclaimer":{"type":"string"},"generation":{"type":"integer"},"parameters":{"type":"object","additionalProperties":{"type":"number"}},"attribution":{"type":"string"},"calibration":{"type":"array","items":{"type":"object","properties":{"n":{"type":"integer"},"bucket":{"type":"string"},"implied":{"type":"number"},"realized":{"type":"number"},"mean_return":{"type":"number"}}}},"data_cutoff":{"type":"string"},"generated_at":{"type":"string"}}}}}}},"responseSchema":{"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"}},"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.25","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.25/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.25","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.25","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_0PFMOEwxwTf7OX3Qpf6_9","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.25","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Backtests fixed trading rules (favorite_hold or longshot_hold) against resolved Polymarket prediction markets and returns statistical performance metrics","exampleAgentPrompt":"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.","exampleUseCases":[{"title":"Politics market strategy evaluation","prompt":"Backtest the favorite_hold rule on Polymarket politics markets from 2023-01-01 to 2025-01-01, entering when YES price is at or above 0.80, filtering to markets with at least $10,000 lifetime volume — give me hit rate, mean return, and max drawdown."},{"title":"Longshot contrarian strategy research","prompt":"Run a longshot_hold backtest on all Polymarket categories from 2022-01-01 to 2024-12-31 with a threshold of 0.10 and minimum volume of $1,000, and tell me the hit rate and mean return by year."},{"title":"Crypto prediction market calibration check","prompt":"Test the favorite_hold rule on crypto Polymarket markets over the past two years with an 0.90 threshold and show me the calibration buckets — I want to know how well the crowd-implied probabilities match actual outcomes."}],"resultDescription":"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.","failureModes":["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"],"whenToPreferThis":"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).","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-09-15T18:39:03.901Z","isFirstParty":false}