Goal: Build an automated betting system that exploits statistical patterns in UK horse racing markets. Not gambling. Algorithmic trading on betting exchanges.
A friend came up with the core idea and an algorithm: a recovery-based betting strategy where the statistical probability of winning within 9 consecutive races was high enough to be profitable. If you lose, you re-bet with adjusted stakes to recover the loss in the next race. The math said it worked. The math was mostly right.
I was the engineer. He was the domain expert. The plan: build the platform, prove the algorithm, find investors, scale it, maybe sell it to a Malta-based betting company.
I coded the entire thing while traveling for freelance work. In a comfy lounge chair in a hotel lobby, sipping on a glass of white wine. The algorithm variants were named during late-night brainstorming sessions: Kermit, Topcat, John, Kylie, Steve, Britney, Bob. Each one a different tuning of the same core strategy. I have no idea which ones were named after real people and which ones were just funny at 11pm with a whisky.
The system wasn't picking winners. It was detecting market movement and exploiting price inefficiencies.
THE CORE: STEAM DETECTION
A "steam" in betting markets is a rapid odds drop — the price collapses because informed money is flooding in before a race. The system watched for these patterns:
Back low, lay high. The spread is profit. The race result is irrelevant if both legs execute.
THE BRAIN: STEAMYBRAIN (476 lines)
The algorithm engine that built the complete Betfair odds ladder (1.01 to 10.0, with varying tick sizes per range), defined steam thresholds for every starting price bracket, and configured drift tolerances. Every price range had its own entry/exit parameters. Deeply tuned. Multiple config versions for A/B testing different strategies.
THE EXECUTOR: KERMIT (279 lines)
The back-and-lay arbitrage engine. Places the BACK bet when steam is detected. Monitors for drift. Places the LAY bet when recovery begins. Aborts if the price crashes below the floor. Operates in a 3-minute pre-race window. Calculates lay stakes dynamically based on the back entry price.
THE BACKTESTER: STEAMWORKS (215 lines)
Monte Carlo-style simulation engine. Replayed millions of historical bets across years of data. Tweakable parameters for sensitivity, entry thresholds, drift tolerance. Generated CSV reports and P&L curves. This was the R&D lab where strategies were born and killed.
All of this — built without AI, without machine learning libraries, without Python notebooks. Pure Ruby, pure logic, pure pattern recognition. Data crunching across millions of records from the comfort of a hotel lobby.
The system tracked both Betfair and BetDAQ simultaneously. Same races, same horses, different odds.
A "Supermatch" model handled identity reconciliation across exchanges — matching the same horse in the same race on both platforms. This enabled cross-exchange arbitrage: back at one exchange, lay at the other, guaranteed profit from the price difference.
The BetDAQ integration used SOAP/XML (because of course it did — this was the era). The Betfair integration used REST with SSL certificate authentication. Both APIs polled every 10 seconds during active racing. Sidekiq workers processed candidates in parallel.
BetSquid was designed as a subscription product:
The idea was: prove the algorithm, show the P&L charts, sell subscriptions to punters who want to automate their betting. My partner built presentations. Designed a cool logo. Approached Malta-based betting companies. We had big goals.
Nobody invested. Nobody subscribed. The product was built. The marketing never happened. Classic Dan: "you gotta have the product first." So I built it. All 646 commits of it. And we never sold it.
What happened:
It worked. Until it didn't.
The algorithm was sound in backtesting. The Monte Carlo simulations showed consistent profitability across years of historical data. Live trading confirmed it — for a while. Money was being made. The math was holding.
Then the edge cases arrived. Markets are manipulated. Weather changes cause unpredictable results (a muddy track in Cheltenham rewrites every probability). The recovery strategy that "statistically guaranteed" a win within 9 races hit streaks that the statistics said were improbable but the universe didn't care about statistics.
The investor search went nowhere. Malta betting companies weren't interested. The presentation deck gathered dust. And eventually, like every pattern in this archive, the energy moved elsewhere.
But the data crunching — millions of bets analyzed for patterns, Monte Carlo simulations across years of historical data, odds ladder construction, cross-exchange arbitrage logic — all of that was built by one person in Ruby, without AI, without ML frameworks, without anything except logic and persistence and whisky. That counts for something.