The problem
Exchange traders often work from spreadsheets and gut feeling. They have no safe place to test a strategy before real money is involved, and no single record of stakes, limits and results. There was also a hard limit: during testing, Betfair Italy refused betting requests sent through its API from datacenter servers.
What I built
I built BetPilot AI, an installable web platform for analysis, risk control and simulation, where every strategy starts in paper trading.
- Visual strategy builder — strategies are saved as a declarative blueprint, checked against a strict whitelist. No user code is ever executed.
- AI strategy assistant — the user describes a strategy in plain words and Claude (Anthropic) turns it into a blueprint, or improves an existing one. If the answer fails validation, the error goes back to the model for another attempt.
- Simulation engine — backtests, replays and comparisons run as background jobs. The matching engine models liquidity, partial matches, slippage and latency, and it is deterministic: the same inputs give the same result.
- Risk engine and signals — budget limits (stake range, daily and weekly maximum loss, odds range) and a stake advisor: one quarter Kelly capped at 5% of the bankroll when a probability is given, otherwise the 2% rule. Every signal shows fair odds and expected value.
- Real journal — the user logs each real bet in one click; bankroll, P&L, ROI and win rate stay up to date.
- Live data — match statistics from API-Football and exchange prices from a read-only agent on the user’s computer.
- Security and records — two-factor login, encrypted secrets, per-user data isolation, audit log, reports in PDF, CSV and XLSX, notifications by email, push and webhook.
How it performs
- An automated test suite, including a test that proves the simulation engine cannot send real orders.
- 18 backend modules and 42 data models in the database schema.
- 7 sports and 6 stake-sizing methods supported by the strategy format.
Built with
Front end in Next.js, React and TypeScript with Tailwind CSS and Recharts, exported as static files. Back end in NestJS with Clean Architecture, domain-driven modules and CQRS, on PostgreSQL through Prisma. Redis and BullMQ run the job queue, with a PostgreSQL fallback. Integrations: the Anthropic API, API-Football and the Betfair read-only API.
Why it was done this way
When the exchange blocked server-side betting, I changed the model. BetPilot analyses, sizes the stake and keeps the accounts; the person places the bet. For market data I wrote a local agent that calls only Betfair’s read methods and keeps credentials on the user’s PC. Betting methods are blocked by construction, so the software stays a decision-support tool.


