Build an arbitrage bot in Python with TickOdds
What we're building
A surebet scanner that:
- Pulls live bet365 odds from TickOdds via WebSocket
- Pulls Betfair Exchange lay prices for the same market
- Computes whether there's a positive-expected-value surebet
- Alerts you on Telegram when one appears
Full source at the end.
Step 1 — set up TickOdds
Sign up at tickodds.com/#pricing and grab a Live or Pro key. For a live in-play arb scanner, you want the Pro tier (2000 req/min, 100 concurrent WebSocket sessions).
pip install websockets requests aiohttp python-telegram-botStep 2 — connect to the TickOdds WebSocket
import asyncio, json, websockets
TICKODDS_KEY = "your_key_here"
async def stream_tickodds():
uri = f"wss://api.tickodds.com/ws/live?apiKey={TICKODDS_KEY}"
async with websockets.connect(uri) as ws:
await ws.send(json.dumps({
"action": "subscribe",
"sports": ["soccer", "tennis"]
}))
async for msg in ws:
yield json.loads(msg)Step 3 — pair with Betfair Exchange
Betfair has its own Exchange Stream API. Open a second WebSocket, authenticate with your app key, subscribe to the same markets. Cache the latest lay price per market ID.
Step 4 — compute the arb
For a two-way market (tennis, no-draw soccer):
def surebet_pct(back_price: float, lay_price: float) -> float:
# Positive if there's an arb
if back_price <= 1 or lay_price <= 1:
return 0.0
implied = 1/back_price + 1/lay_price
return (1 - implied) * 100If surebet_pct > 1.0, you have an arb after fees. Anything below that is probably eaten by commissions.
Step 5 — alert
Wire the Telegram bot SDK to send a message when a surebet appears. Throttle to one alert per market ID per 60 seconds so you don't spam yourself.
Full source
See the companion GitHub repo for a complete, tested implementation including market matching (bet365's market names don't match Betfair's exactly — you'll need a fuzzy-matching table) and staking math.
Next steps
- Add a third book via another feed for three-way arbs
- Log every detected arb to a database for post-hoc analysis
- Graduate to live-only in-play arbs once your comfort grows
An arb bot is a great starter project because it forces you to get comfortable with real-time data, multi-source merging, and fast reaction loops — the same primitives that power any more-advanced sports trading model.
Try TickOdds
Free Developer tier, no credit card. Upgrade to Starter ($19/mo) when you need more sports or faster refresh.