Articles
Track, Stage 1: archiving a bookmaker and testing whether its prices can be beaten
August to October 2026 · Python, ClickHouse, Next.js, scikit-learn, TimesFM

The question
The idea behind this project started long before I built the archive.
When a football team is two goals ahead late in a match, the odds on them winning are naturally short. But I suspected they were still a bit too generous: in other words, underpricing how rarely two-goal leads evaporate.
In November 2023, I wrote a simple Python script to test this hunch. It polled SportyBet's live matches every minute and sent me an SMS alert whenever a team held a two-goal lead between the 60th and 70th minute. I placed the bets manually. It worked surprisingly well: I turned 100 Ghanaian cedis into 1,000 cedis, and then I stepped away.
In May 2025, I decided to automate the whole process. I built a bot running on my Mac and a Raspberry Pi. It logged into the bookmaker through a headless browser, placed fixed-stake bets automatically whenever a match qualified, and sent notifications to a Telegram channel.
This time, the bot consistently lost money.
Either the market had adapted and erased the edge, or the edge had never existed and my early run was just dumb luck. The problem with simply placing live bets is that it cannot tell those two possibilities apart. Your account balance only tells you how yesterday went; it does not tell you if your rule has a genuine mathematical advantage.
To find out, I stopped betting and decided to build something that could measure the market properly. Doing that required data that no public API provides: every single price a bookmaker publishes throughout a match, captured second by second alongside the live score and the match clock.
In August 2026, that project became Track. Stage 1 was an archiving pipeline: a collector captured every live and upcoming price SportyBet published, a Next.js dashboard visualized the data, and an analysis pipeline tested one fundamental question: can a bookmaker's in-play prices actually be beaten?
What I built
| Component | Technology and Role |
|---|---|
| Collector | Python. Runs a live scan every 60 seconds to fetch in-play matches and their full odds books, an hourly scan for matches kicking off in the next 3 hours, and a reconciliation job matching finished games against official result feeds. |
| Archive | ClickHouse, self-hosted on Coolify. Originally built on PostgreSQL, then migrated once data volume became a database bottleneck. |
| Dashboard | Next.js. Provides live, upcoming, and historical match boards, with detailed match pages charting market implied probabilities minute by minute. |
| Analysis | Python and SQL executed directly in ClickHouse, with predictive modeling in scikit-learn and Google TimesFM. |
What ten weeks of continuous collection produced (August 18 to October 28, 2026):
- 32,668 completed matches with confirmed results across 879 leagues
- 486 million recorded odds changes across 427 betting market types (match result, total goals, handicaps, correct score, corners, and more)
- 2.7 million live match-state snapshots (score, minute, period) and 102,000 goals
- 39.7 GB of raw data compressed into just 2.2 GB using ClickHouse columnar compression (an 18x reduction)
Engineering problems along the way
Network latency was the hidden bottleneck: My initial collector executed individual SQL statements per match over an SSH tunnel with a 190 ms round trip. A single scan of 400 matches spent several minutes just waiting on network handshakes. Local benchmarks using a stub database completely hid this latency. Batching database writes into single bulk inserts per table cut the collection cycle from minutes down to 17 seconds.
A missing record is not an event: During half-time breaks, SportyBet temporarily drops matches from its active live feed. My collector initially interpreted that absence as the match ending, causing dozens of games to be marked as finished at the 45-minute mark. Their second halves were never recorded. The giveaway was seeing twelve unrelated matches conclude at the exact same second. The fix was simple: require an absence to persist past a generous grace period, and rely exclusively on the official results feed to finalize a match.
Inferring goals without an event feed: The bookmaker publishes raw scores rather than discrete goal events. I built an event-detection layer that infers goals by comparing score changes between consecutive snapshots, reconstructing a clean chronological goal history.
Suspended markets produce phantom edges: An early backtest showed an apparent 4.7% positive return on over/under markets at the 60-minute mark. Looking closer, all 1,528 winning bets were in markets the bookmaker had already suspended or settled. Once I filtered out suspended prices, the edge disappeared entirely. That taught me a core rule: always treat an apparent edge with deep suspicion until execution conditions are verified.
A stale DNS cache halted ingestion for 36 hours: An Nginx reverse proxy resolved the database container's hostname once when starting up. When the database container restarted with a new internal IP address, the proxy kept accepting incoming connections and immediately dropping them. Moving the collector directly onto the same Docker network as the database eliminated the proxy layer entirely. I also added a Telegram watchdog that alerts me if ingestion stalls for more than five minutes.
Backtesting the original idea
Before testing complex machine learning models, I backtested the original two-goal-lead strategy against the complete archive.
To keep the evaluation honest, I set strict ground rules:
- One bet per match per rule: A single match generates hundreds of tick-level price updates. Treating each price change as an independent betting opportunity artificially inflates statistical sample size.
- Remove the bookmaker's vigorish: SportyBet's match-result odds sum to roughly 109% to 110% implied probability. Dividing each individual outcome's implied probability by the market total yields the true consensus belief.
- High win rates do not equal profit: In betting, expected value equals probability multiplied by odds minus one. Winning 95% of your bets still loses money if the average payout is too low to cover the 5% you lose.
- Measure statistical uncertainty: Any measured return inside plus or minus two standard errors is likely noise. If you test 16 different parameter slices, one will look profitable purely by chance at a 5% significance level.
The findings were definitive: the two-goal-lead thesis is completely refuted by the data.
Teams that the market priced at over 85% probability went on to win 95% to 97% of the time. But because the payout odds were so compressed, flat-betting these leads generated returns between -2% and +0.2%. You win almost every weekend, but you slowly bleed capital to the bookmaker's margin.
Across every minute of play and for both home and away teams, flat betting on match results produced negative returns. Long-shot outcomes were significantly overpriced, demonstrating the classic favorite-longshot bias common to betting markets. The only pocket that hinted at positive returns (65% to 85% favorites in the second half, showing +2% to +5%) never cleared its statistical error margin.
Can a model beat the market?
If simple heuristics fail, can a machine learning model find an edge?
The core prediction task: at any given point in a match, predict the final outcome (home win, draw, or away win).
Experimental setup
- Four key match moments: Kickoff (0'), mid-first half (22'), half-time (45'), and mid-second half (67').
- Feature inputs: The live score, the match clock, and the closing pre-match odds (which reflect market expectations for home, draw, away, and over/under 2.5 total goals). One variant also included the current live in-play odds.
- Strict chronological split: Models were trained on the earliest 75% of matches and evaluated on the final 25% (October 11 to October 28). Random cross-validation would cause data leakage by training and evaluating on the same leagues, teams, and tournament schedules.
- The bookmaker is the benchmark: The bookmaker's margin-adjusted live odds are themselves a market forecast. Any model that fails to outperform those odds has learned nothing beyond what the market already prices in.
- Filtering criteria: Extra-time matches were excluded, and predictions were only scored if the live price was updated within the last three minutes (older quotes reflect suspended markets rather than active trading).
The models
| Model | Architecture and Description |
|---|---|
| Poisson goals model | The classic quantitative football baseline. Each team's expected goal rate is inferred from closing prices, and remaining goals are simulated from Poisson distributions scaled to time remaining. It requires zero parameter training aside from the historical distribution of goal arrival times. |
| Logistic regression | A calibrated linear baseline. |
| Gradient-boosted trees | A tree ensemble capable of capturing non-linear feature interactions (for example, a one-goal lead is far more decisive at minute 67 than at minute 22). Evaluated both with and without live in-play prices. |
| Google TimesFM 2.5 | A pretrained 200-million-parameter time-series foundation model, evaluated zero-shot. Because TimesFM forecasts continuous sequences rather than classification labels, it was fed the minute-by-minute implied probability spread (P(home) - P(away)) and asked to project the trajectory through minute 90. |
Evaluation results
Accuracy represents the percentage of test matches where the model's most probable prediction matched the actual full-time result:
| Moment | Test Matches | Always Home | Bookmaker | Poisson | Logistic | Boosted Trees | Trees + Live Odds | TimesFM |
|---|---|---|---|---|---|---|---|---|
| Kickoff | 5,009 | 44.6% | 53.9% | 53.9% | 54.1% | 53.7% | 53.7% | N/A |
| 22' | 2,754 | 45.2% | 59.8% | 58.8% | 58.9% | 58.3% | 58.9% | 58.4% |
| Half-time | 3,321 | 43.6% | 62.9% | 62.8% | 62.2% | 61.8% | 62.5% | 60.0% |
| 67' | 3,175 | 40.1% | 67.1% | 67.4% | 67.8% | 66.2% | 66.6% | 66.6% |
Each accuracy measurement carries a confidence margin of roughly plus or minus 1.5 to 2.0 percentage points. When evaluated on log loss (which measures probability calibration rather than discrete picks), the bookmaker's implied probabilities were best or tied at every single moment.
Calibration across models: The models were remarkably well calibrated. When our gradient-boosted model predicted a 75% probability of winning, the team won approximately 75% of the time. Here is the calibration breakdown at half-time:
| Predicted Probability | Match Count | Mean Prediction | Observed Win Rate |
|---|---|---|---|
| 40% to 50% | 747 | 44.7% | 43.8% |
| 50% to 60% | 511 | 54.5% | 56.6% |
| 70% to 80% | 448 | 74.8% | 76.6% |
| 80% to 90% | 461 | 85.2% | 86.1% |
| 90% to 100% | 288 | 94.2% | 94.4% |
What the results tell us
Every model converged on the bookmaker, and none could beat it:
Four distinct model families, ranging from a simple two-parameter Poisson model to a 200-million-parameter foundation model, landed within a single percentage point of the market and of one another.
When completely different modeling approaches hit the exact same ceiling, the model architecture is not the limitation. The bottleneck is the information itself. The match score and elapsed time are public knowledge, and the market incorporates them instantly. A model cannot generate an edge without proprietary information that the market lacks.
The foundation model performed worst, and the reason is illuminating:
We benchmarked TimesFM against the simplest possible naive forecast: holding the market's current probability spread flat through minute 90. The flat baseline outperformed TimesFM at every single point in the match (60.1%, 62.4%, and 68.0% compared to TimesFM's 58.4%, 60.0%, and 66.6%).
Because market odds already incorporate the collective expectation of future goals, subsequent price movements resemble a random walk. Trying to project momentum or trend lines in financial odds simply introduces noise. A time-series model designed to find seasonal patterns in retail demand or website traffic finds nothing useful here, which is strong proof that the in-play betting market is highly efficient.
Draws create a structural blind spot:
In football, models rarely assign a higher individual probability to a draw than to a win. As a result, the 22% to 28% of matches that finish level are almost never predicted as the single most likely outcome. This places an artificial ceiling on any classification accuracy benchmark that evaluates only the top pick.
Stage 2
Since modeling improvements cannot extract edge from public scoreboards alone, Stage 2 focuses on expanding the data inputs.
Bookmaker price feeds contain odds and scores, but no underlying match performance metrics. Platforms like Sofascore publish live in-game statistics, including shot counts, dangerous attacks, possession shares, expected goals (xG), and momentum charts.
The upcoming experiment will benchmark odds-only models against models trained on odds plus live match performance across the same matches and chronological splits. If in-play statistics offer information that odds have not yet absorbed, that test will reveal it. Because sports data aggregators actively block cloud data centers, Stage 2's ingestion collector runs locally on a Raspberry Pi at home.
Gallery








Comments