> ## Documentation Index
> Fetch the complete documentation index at: https://docs.predexon.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Quant & data trader

> From zero to a working backtest in 10 minutes. The data, signals, and tools quants reach for first.

You're here to find edges in prediction-market data. This guide gets you from API key to a runnable backtest, then points you at the deeper material.

**You'll be ready to:**

* Pull historical orderbook + trade + candle data for any market
* Reconstruct any wallet's full position history and P\&L
* Build smart-money signals from the leaderboard endpoint
* Stream live signals (trades, pending trades, orderbook) over WebSocket

***

## 10 minutes to a backtest

Goal: pull 30 days of orderbook snapshots for the highest-volume open market, plus the trade tape, plus the candle series — enough to run a real backtest.

```python theme={null}
import os, requests, pandas as pd, time

API_KEY = os.environ["PREDEXON_API_KEY"]
BASE = "https://api.predexon.com"
HEADERS = {"x-api-key": API_KEY}

# 1. Find the highest-volume open market
top = requests.get(
    f"{BASE}/v2/polymarket/markets",
    headers=HEADERS,
    params={"status": "open", "sort": "volume", "limit": 1},
).json()["markets"][0]

condition_id = top["condition_id"]
token_id = top["outcomes"][0]["token_id"]  # "Yes" side
print(f"Backtesting: {top['title']}")

# 2. Pull 30 days of hourly candles (seconds for candles)
end_s = int(time.time())
start_s = end_s - 30 * 24 * 3600
candles = requests.get(
    f"{BASE}/v2/polymarket/candlesticks/{condition_id}",
    headers=HEADERS,
    params={"interval": 60, "start_time": start_s, "end_time": end_s},
).json()
candles_df = pd.DataFrame(candles)
print(f"Candles: {len(candles_df)} bars")

# 3. Pull the trade tape (seconds for trades)
trades = requests.get(
    f"{BASE}/v2/polymarket/trades",
    headers=HEADERS,
    params={"token_id": token_id, "start_time": start_s, "end_time": end_s, "limit": 1000},
).json()
print(f"Trades: {len(trades)}")

# 4. Walk historical orderbook snapshots (milliseconds for orderbook)
end_ms = end_s * 1000
start_ms = start_s * 1000
snapshots, cursor = [], start_ms
while cursor < end_ms:
    page = requests.get(
        f"{BASE}/v2/polymarket/orderbooks",
        headers=HEADERS,
        params={"token_id": token_id, "start_time": cursor, "end_time": end_ms, "limit": 200},
    ).json()
    if not page: break
    snapshots.extend(page)
    cursor = page[-1]["timestamp"] + 1
print(f"Orderbook snapshots: {len(snapshots)}")
```

That's three free endpoints, no rate-limit risk, \~30 lines of code, ready for pandas/numpy/whatever your strategy framework is.

<Tip>
  Every endpoint used here is **free and unlimited**. Run as many backtests as you want.
</Tip>

***

## The data tools quants reach for first

<CardGroup cols={2}>
  <Card title="Orderbook history" icon="layer-group" href="/api-reference/markets/orderbooks">
    Per-token L2 snapshots from Jan 1 2026. Simulate fills against the real book — see [Orderbook Replay](/data-signals/backtesting/orderbook-replay) for the pattern.
  </Card>

  <Card title="Candlesticks" icon="chart-candlestick" href="/api-reference/markets/candlesticks">
    OHLCV at 1m / 5m / 15m / 1h / 4h / 1d. By condition (market-level) or per-token (each outcome). Pair with trades for VWAP reconciliation.
  </Card>

  <Card title="Trade tape" icon="receipt" href="/api-reference/trading/trades">
    Every fill on Polymarket and Kalshi. Filter by token, wallet, time range. Ground truth for execution simulation.
  </Card>

  <Card title="Wallet P&L" icon="wallet" href="/api-reference/wallet/pnl">
    Realized + unrealized P\&L time series for any wallet. The basis for smart-money cohort backtests.
  </Card>

  <Card title="Smart money for a market" icon="brain" href="/api-reference/smart-money/smart-money-market">
    Net positioning of profitable wallets in any market right now. Great for confirmation signals.
  </Card>

  <Card title="Leaderboards" icon="trophy" href="/api-reference/analytics/leaderboard">
    Top wallets globally or per-market, sortable by realized profit, ROI, volume, or win rate.
  </Card>

  <Card title="Cross-venue matching" icon="left-right" href="/api-reference/matching/find-matches">
    Find the same outcome on multiple venues — the basis of every cross-venue arb strategy.
  </Card>

  <Card title="Pending-trade signals (WS)" icon="clock" href="/websocket/pending-trades">
    Mempool detection of fills 3–5 seconds before they confirm. Used by latency-sensitive strategies.
  </Card>
</CardGroup>

***

## Backtesting walkthroughs

Three production-grade patterns we've written up:

<CardGroup cols={3}>
  <Card title="Orderbook replay" icon="rotate-left" href="/data-signals/backtesting/orderbook-replay">
    Simulate fills against historical L2 state. The gold-standard for capacity-sensitive strategies.
  </Card>

  <Card title="Candle + trade reconciliation" icon="check-double" href="/data-signals/backtesting/candle-trade-reconciliation">
    Fast candle-driven backtests with trade-tape validation. Pass 1 is cheap; pass 2 keeps you honest.
  </Card>

  <Card title="Signal backtesting" icon="flask" href="/data-signals/backtesting/signal-backtest">
    How to honestly test smart-money, top-holders, and pending-trade signals before sizing into them.
  </Card>
</CardGroup>

***

## Going live

Once a strategy backtests well, swap REST polling for WebSocket streams using the same data shapes.

| What you backtested with                          | What you stream live with                                         |
| ------------------------------------------------- | ----------------------------------------------------------------- |
| `GET /v2/polymarket/trades`                       | [WS trades channel](/websocket/trades)                            |
| `GET /v2/polymarket/orderbooks` (snapshots)       | [WS orderbook channel](/websocket/orderbook) (snapshots + deltas) |
| `GET /v2/polymarket/activity`                     | [WS activity channel](/websocket/activity)                        |
| Pending-trade replay (not available historically) | [WS pending-trades](/websocket/pending-trades)                    |

Read [WebSocket Overview](/websocket/overview) for connection patterns, subscription limits, and reconnect handling.

***

## Common quant recipes

<CardGroup cols={2}>
  <Card title="Detect smart-money entry" icon="user-secret" href="/start-here/cookbook/smart-money-entry">
    Wallet leaderboard + smart-money endpoint + alert path.
  </Card>

  <Card title="Cross-venue arbitrage" icon="scale-balanced" href="/start-here/cookbook/cross-venue-arbitrage">
    Matched pairs + live spreads + two-leg fill.
  </Card>

  <Card title="Front-run from pending trades" icon="clock" href="/start-here/cookbook/pending-trade-frontrun">
    Mempool WS + size + execute before confirmation.
  </Card>

  <Card title="Copy-trade a wallet" icon="users" href="/start-here/cookbook/copy-trade-wallet">
    Subscribe wallet → mirror each fill. End-to-end.
  </Card>
</CardGroup>

***

## What you should read next

<CardGroup cols={2}>
  <Card title="Data & Signals overview" icon="chart-line" href="/data-signals/overview">
    Full map of every data endpoint, organized by utility.
  </Card>

  <Card title="Best Practices" icon="shield-check" href="/start-here/best-practices">
    Pagination, retries, rate-limit handling, WebSocket reconnect logic.
  </Card>
</CardGroup>
