Backtest tennis surface Elo in Pandas with zero lookahead bias
Download the free public sample CSV in seconds, load 2.25M+ matches enriched with pre-match Overall, Hard, Clay, and Grass Elo plus opening/closing odds via Business CSV ($299/mo, 0 REST credits), and score upcoming matches via REST.
Pro $59/mo: real-time scores, full archive since 1968, match webhooks. Free: 500 calls/month, live 60 s delayed, last 30 days. Read the docs
$ curl -s "https://api.citoapi.com/api/v1/exports/sample/tennis/matches.csv" | head -n 5
In short
Load matches-master.csv.gz and matches-delta.csv.gz?hours=24 into Pandas using canonical match_id, winner_surface_elo_pre, loser_surface_elo_pre, elo_win_prob, and winner_close_odds with zero lookahead bias, then evaluate live edges via /tennis/odds/upcoming and /tennis/players/{id}/elo.
1. Inspect the CSV schema free (no API key needed)
Before pulling the full archive, inspect the exact column layout on the unauthenticated 100-row sample CSV at GET /api/v1/exports/sample/tennis/matches.csv (and players.csv). Business CSV ($299/mo, +$99/mo per extra sport) uses the exact same columns for both the Master Baseline (matches-master.csv.gz) and Rolling Daily Deltas (matches-delta.csv.gz?hours=24), consuming 0 REST credits.
| CSV column | Meaning in backtests |
|---|---|
| match_id | Canonical match primary key (returned in X-CSV-Primary-Key header for idempotent upserts) |
| match_date, surface, tour, round, best_of | Strict chronological sort key, court surface (Hard/Clay/Grass/Carpet), tour & format |
| winner_id, loser_id, winner_rank, loser_rank | Canonical player IDs and official ranking as of match day (no lookahead) |
| winner_elo_pre, loser_elo_pre | Overall Elo ratings immediately before first ball |
| winner_surface_elo_pre, loser_surface_elo_pre | Surface-specific Elo ratings immediately before first ball |
| elo_win_prob | Pre-match Elo win probability for the eventual winner (0 to 1) |
| winner_open_odds, loser_open_odds, winner_close_odds, loser_close_odds | Opening & closing prediction-market decimal odds where traded |
load_and_backtest.py — Load sample or Business CSV into Pandas & score calibration
import io
import os
import numpy as np
import pandas as pd
import requests
API = "https://api.citoapi.com/api/v1"
# 1) Free schema test (no key required) OR Business CSV Master Baseline ($299/mo, 0 REST credits)
USE_MASTER = bool(os.getenv("USE_BUSINESS_CSV"))
if USE_MASTER:
resp = requests.get(
f"{API}/exports/tennis/matches-master.csv.gz",
headers={"x-api-key": os.environ["CITO_API_KEY"]},
timeout=120,
)
resp.raise_for_status()
df = pd.read_csv(io.BytesIO(resp.content), compression="gzip", low_memory=False)
else:
df = pd.read_csv(f"{API}/exports/sample/tennis/matches.csv")
# 2) Filter to completed matches with valid pre-match surface Elo (zero lookahead)
clean = df.dropna(subset=["winner_surface_elo_pre", "loser_surface_elo_pre", "elo_win_prob"]).copy()
clean["match_date"] = pd.to_datetime(clean["match_date"])
clean = clean.sort_values(["match_date", "match_id"])
# Log-loss and Brier score of pre-match Elo win probabilities
p = clean["elo_win_prob"].clip(1e-6, 1 - 1e-6)
brier = np.mean((1.0 - p) ** 2)
log_loss = np.mean(-np.log(p))
print(f"Matches: {len(clean):,} | Brier: {brier:.4f} | Log-loss: {log_loss:.4f}")
# 3) Compare Elo probability against closing prediction-market implied probability where traded
traded = clean.dropna(subset=["winner_close_odds", "loser_close_odds"]).copy()
if not traded.empty:
traded["mkt_prob_winner"] = 1.0 / traded["winner_close_odds"]
traded["elo_edge"] = traded["elo_win_prob"] - traded["mkt_prob_winner"]
pos_edge = traded[traded["elo_edge"] > 0.04]
print(f"Traded matches: {len(traded):,} | +4% Elo edge count: {len(pos_edge):,}")import io
import os
import pandas as pd
import requests
# Keep your local Parquet / DuckDB / Postgres warehouse current at 0 REST credits
r = requests.get(
"https://api.citoapi.com/api/v1/exports/tennis/matches-delta.csv.gz",
params={"hours": 24},
headers={"x-api-key": os.environ["CITO_API_KEY"]},
timeout=60,
)
r.raise_for_status()
pk = r.headers["X-CSV-Primary-Key"] # "match_id"
delta = pd.read_csv(io.BytesIO(r.content), compression="gzip", low_memory=False)
master = pd.read_parquet("tennis_master.parquet")
updated = pd.concat([master[~master[pk].isin(delta[pk])], delta], ignore_index=True)
updated.to_parquet("tennis_master.parquet", index=False)
print(f"Upserted {len(delta)} rows on {pk}; total archive: {len(updated):,}")2. Live REST parity for pre-match inference
Your live scoring script uses the exact same canonical player IDs and Elo fields via GET /tennis/rankings/elo, GET /tennis/players/{player_id}/elo, GET /tennis/odds/upcoming, and GET /tennis/matches?include=stats,elo,odds. Note that queries inside 0–90 days and live/upcoming endpoints cost 1 credit, while >=91-day REST queries carry 5x/bulk multipliers and monthly >90d sub-caps — which is why quant teams run historical backtests on Business CSV (0 REST credits, Unlimited >90d sub-cap) and keep REST credits for live inference.
Live Hard-court Elo leaderboard
curl "https://api.citoapi.com/api/v1/tennis/rankings/elo?surface=Hard&limit=5" \
-H "x-api-key: YOUR_API_KEY"{
"success": true,
"tour": "ATP",
"surface": "hard",
"total": 3792,
"items": [
{
"player_id": "atp_206173",
"full_name": "Jannik Sinner",
"tour": "ATP",
"country_code": "ITA",
"is_active": true,
"elo_overall": 2843.6,
"elo_hard": 2733.4,
"elo_clay": 2567.2,
"elo_grass": 2227.9,
"elo_indoor": 2396.9,
"peak_elo_overall": 2851.9,
"peak_elo_date": "2026-05-17",
"matches_rated": 580,
"hard_matches": 368,
"clay_matches": 162,
"grass_matches": 50,
"last_match_date": "2026-07-12",
"rank": 1,
"rating": 2733.4,
"surface": "hard",
"id": "atp_206173",
"name": "Jannik Sinner"
},
{
"player_id": "atp_207989",
"full_name": "Carlos Alcaraz",
"tour": "ATP",
"country_code": "ESP",
"is_active": true,
"elo_overall": 2764.6,
"elo_hard": 2630,
"elo_clay": 2613.7,
"elo_grass": 2243.6,
"elo_indoor": 2271.3,
"peak_elo_overall": 2798.1,
"peak_elo_date": "2026-03-12",
"matches_rated": 492,
"hard_matches": 246,
"clay_matches": 207,
"grass_matches": 39,
"last_match_date": "2026-11-08",
"rank": 2,
"rating": 2630,
"surface": "hard",
"id": "atp_207989",
"name": "Carlos Alcaraz"
},
{
"player_id": "atp_104925",
"full_name": "Novak Djokovic",
"tour": "ATP",
"country_code": "SRB",
"is_active": true,
"elo_overall": 2603.4,
"elo_hard": 2511,
"elo_clay": 2487.4,
"elo_grass": 2277.9,
"elo_indoor": 2293.1,
"peak_elo_overall": 2838.9,
"peak_elo_date": "2016-05-14",
"matches_rated": 1519,
"hard_matches": 919,
"clay_matches": 421,
"grass_matches": 155,
"last_match_date": "2026-11-04",
"rank": 3,
"rating": 2511,
"surface": "hard",
"id": "atp_104925",
"name": "Novak Djokovic"
}
]
}Match payload with stats, Elo & odds inline
curl "https://api.citoapi.com/api/v1/tennis/matches?player_id=atp_206173&year=2025&page_size=1&include=stats,elo,odds" \
-H "x-api-key: YOUR_API_KEY"{
"items": [
{
"id": "atp_2025_0605_374",
"tournament_name": "ATP Finals",
"match_date": "2025-11-09",
"surface": "Hard",
"round_name": "Round Robin",
"score": "7-5 6-1",
"winner": {
"id": "atp_206173",
"name": "Jannik Sinner",
"rank": 2
},
"loser": {
"id": "atp_200000",
"name": "Felix Auger-Aliassime",
"rank": 8
},
"elo": {
"winner_elo_pre": 2802.2,
"loser_elo_pre": 2471.2,
"winner_elo_post": 2805,
"loser_elo_post": 2468.6,
"winner_surface_elo_pre": 2719.9,
"loser_surface_elo_pre": 2400.8,
"winner_surface_elo_post": 2723.4,
"loser_surface_elo_post": 2397.4,
"surface": "Hard",
"elo_win_prob": 0.8666,
"winner_win_prob": 0.8666,
"loser_win_prob": 0.1334
},
"odds": null
}
]
}live_edge_scanner.py — Compare upcoming market odds against surface Elo
import os
import requests
API = "https://api.citoapi.com/api/v1/tennis"
H = {"x-api-key": os.environ["CITO_API_KEY"]}
upcoming = requests.get(f"{API}/odds/upcoming", params={"limit": 25}, headers=H, timeout=10).json()
for item in upcoming["items"]:
p1 = item["home"]["id"]
p2 = item["away"]["id"]
h2h = item.get("h2h") or {}
if not p1 or not p2 or not h2h.get("player1_prob"):
continue
e1 = requests.get(f"{API}/players/{p1}/elo", params={"history_limit": 1}, headers=H, timeout=10).json()
e2 = requests.get(f"{API}/players/{p2}/elo", params={"history_limit": 1}, headers=H, timeout=10).json()
diff = (e1.get("elo_hard") or e1["elo_overall"]) - (e2.get("elo_hard") or e2["elo_overall"])
elo_p1 = 1.0 / (1.0 + 10.0 ** (-diff / 400.0))
print(f"{item['home']['name']} vs {item['away']['name']} | Elo p1: {elo_p1:.3f} | Market p1: {h2h['player1_prob']:.3f}")| Data | Depth |
|---|---|
| Match results (ATP and WTA) | Open Era (1968) to today, plus earlier seasons: 2.1M+ matches with set scores |
| Point-in-time Elo & win probs | Overall, Hard, Clay, Grass & Indoor Elo across 2.1M+ matches since 1968 |
| Weekly rankings | Every published ATP and WTA list since the 1970s, queryable by date |
| Serve and return statistics | Per match where recorded in the archive; every tour-level and Challenger match in the live era |
| Point-by-point | Matches carried live, consistently since June 2026. Not available for older seasons |
| Odds & tick history | Pre-match & live prediction-market prices + liquidity linked by canonical match_id, plus history snapshots |
Test /exports/sample/tennis/matches.csv free today, prototype live odds & Elo on the 3-day Free trial or Pro ($59/mo), and unlock the full 2.25M+ match archive + Daily Delta CSVs on Business CSV ($299/mo).
Plans for tennis
| Free | Starter | Pro | Scale | Business CSV | |
|---|---|---|---|---|---|
| Price | $0 | $15/mo | $59/mo | $100/mo | $299/mo (+$99/mo extra sport) |
| Credits / mo | 500/month | 10,000/month | 250,000/month | 1,000,000/month | 3,000,000/month |
| Rate limit | 10/min | 30/min | 100/min | 400/min | 600/min |
| Live scores | 60 s delayed | 60 s delayed | Real time | Real time | Real time |
| History | Last 30 days | Last 90 days | Full archive (1968-) | Full archive (1968-) | Full archive (1968-) + Master/Delta CSV |
| Deep-history (>90d) sub-cap | 0 | 0 | 50,000/mo (5x narrow / bulk) | 100,000/mo (5x narrow / bulk) | Unlimited in quota |
| Prediction-market odds | 3-day free trial | Upgrade to Pro | Pre-match, live & history | Pre-match, live & history | API + opening/closing CSV |
| Point-in-time Elo | 3-day free trial | Career & leaders | Full 1968- history | Full 1968- history | API + pre-match CSV |
| Webhooks | No | No | Yes | Yes | Yes |
| WebSockets | No | No | +$15/mo (points + odds) | Included | Included (points + odds) |
| Bulk CSV exports | Sample CSV | — | — | — | Master + Daily Delta CSV (0 REST credits) |
| Commercial use | No | 1 product | Yes | Yes | Yes |
Tennis on each plan, as the API enforces it (checked 15 Nov 2026). Paid API plans: 7-day money-back guarantee.
Frequently asked
Ready to go
live ?
Pro unlocks real-time scores, point-by-point, prediction-market odds, point-in-time Elo back to 1968, and webhooks for $59/mo with a 7-day money-back guarantee. Free includes a 3-day odds & Elo trial; Business ($299/mo) delivers full CSV datasets.
Compare every plan