AymarData
Backtest · Bitcoin

Bitcoin Backtest Data: Tick-Level Order Books & Trades

Run Bitcoin backtests on Polymarket BTC Up/Down windows joined to Binance BTCUSDT spot — the same clocks, L2 books and trades AymarData records for research.

Bitcoin strategies that only see candles miss queue dynamics, spread, and short-horizon prediction-market prices. AymarData stores tick-level order books and trades so you can replay BTC Up/Down windows against spot.

Polymarket history starts 2025-06-01 (~207.0M platform messages). Binance spot contributes ~28.0M events. Figures below are as of 2026-10-25.

Inputs

What you need to backtest Bitcoin properly

What a serious backtest needs beyond candles.

Point-in-time L2 books

Sample the Up (and Down) book inside each Polymarket window, and the Binance BTCUSDT book at the same UTC decision time. Mid-only backtests understate cost — use ask to buy and bid to sell.

Trades / aggressive flow

Trade prints show whether your signal coincided with real flow. Pull /v1/trades for both polymarket and binance-spot over the same interval.

Settlements (for Up/Down P&L)

Without settlement, binary P&L is incomplete. Resolve each window with /v1/settlement before aggregating returns.

Aligned clocks

Prefer ts_exchange for economic features and ts_recv for latency studies. Do not mix candle closes from a third vendor with AymarData books without documenting the clock.

Coverage

Live Bitcoin coverage

Instrument pages under /data/polymarket/btc-updown-* and /data/binance/btc-spot publish per-market event counts derived from the same PUBLIC_TOTALS weights used across the catalog.

Polymarket messages

~207.0M

History from 2025-06-01

Binance spot messages

~28.0M

BTCUSDT + majors · from 2025-06-01

Binance perps messages

~74.0M

USDⓈ-M including BTCUSDT

As of

2026-10-25

Public catalog totals

Code

End-to-end Bitcoin backtest (REST + requests)

Lists a BTC 15m window, samples the Up book, and joins a Binance BTCUSDT spot snapshot. Requires AYMARDATA_API_KEY.

import os
import requests

API = "https://api.aymardata.com/v1"
KEY = os.environ["AYMARDATA_API_KEY"]  # export AYMARDATA_API_KEY=ad_live_…
H = {"Authorization": f"Bearer {KEY}", "User-Agent": "aymardata-backtest/1.0"}

def get_book(source: str, market: str, at: str, **extra):
    params = {"source": source, "market": market, "at": at, "depth": 5, **extra}
    r = requests.get(f"{API}/book", headers=H, params=params, timeout=30)
    r.raise_for_status()
    return r.json()

def get_trades(source: str, market: str, start: str, end: str, **extra):
    params = {
        "source": source,
        "market": market,
        "start": start,
        "end": end,
        "limit": 200,
        **extra,
    }
    r = requests.get(f"{API}/trades", headers=H, params=params, timeout=30)
    r.raise_for_status()
    return r.json()["data"]

# 1) Find a recent BTC 15m Up/Down window
mk = requests.get(
    f"{API}/markets",
    headers=H,
    params={"source": "polymarket", "q": "btc-updown-15m", "interval": "15m", "limit": 10},
    timeout=30,
)
mk.raise_for_status()
window = next(r["market"] for r in mk.json()["data"] if "btc-updown-15m-" in r["market"])
hist = next(r["history_from"] for r in mk.json()["data"] if r["market"] == window)

# 2) Point-in-time Polymarket Up book
poly = get_book("polymarket", window, hist, outcome="up")
poly_mid = None
if poly.get("bids") and poly.get("asks"):
    poly_mid = (poly["bids"][0]["price"] + poly["asks"][0]["price"]) / 2

# 3) Matching Binance spot mid (market id is BTCUSDT)
# Use a short window around the same clock for trades + a book snapshot.
spot_at = "2026-10-23T10:00:00Z"
spot = get_book("binance-spot", "BTCUSDT", spot_at)
spot_mid = None
if spot.get("bids") and spot.get("asks"):
    spot_mid = (spot["bids"][0]["price"] + spot["asks"][0]["price"]) / 2

start = "2026-10-23T10:00:00Z"
end = "2026-10-23T10:01:00Z"
spot_trades = get_trades("binance-spot", "BTCUSDT", start, end)

print({
    "polymarket_window": window,
    "poly_mid": poly_mid,
    "spot_mid": spot_mid,
    "spot_trades": len(spot_trades),
    "spread_poly": poly.get("spread"),
    "spread_spot": spot.get("spread"),
})

API base https://api.aymardata.com. Set AYMARDATA_API_KEY from your dashboard. Examples use requests. Any P&L, win-rate, or edge figure derived from these snippets is illustrative output — not a real result.

Free samples

Download sample CSV / Parquet

No key required — small files for schema and local smoke tests.

FAQ

Common questions

What is the best starting market for a Bitcoin backtest?

Start with Polymarket btc-updown-15m for dense, settled binaries, and hedge or feature-engineer with Binance BTCUSDT spot. Add perps when you need funding.

Which market id should I pass for Binance BTC?

Use BTCUSDT (or btcusdt) with source=binance-spot or binance-perps. Hyphenated BTC-USDT ids are not accepted by the live API.

Can I download free Bitcoin sample data?

Yes — CSV and Parquet samples for Polymarket and Binance spot are linked on this page under Free samples.

Related

Data pages and guides

Catalog leaves for schema and samples; guides for longer walkthroughs.

Run your first backtest with real ticks

Get a key, paste the snippet above, then expand to the full catalog.

Educational content, not trading or investment advice. Past data doesn't predict future results.