Create a Command Line Arbitrage Betting App in Rust

Published on

Read time
2 min read

Introduction

In this article, we’ll create a simple command line application using Rust. It will fetch data from an API that aggregates sports bets and calculate whether there are any arbitrage opportunities in that data.

We’re using Rust simply as a learning opportunity—it would be quicker to spin this up using Node.js or Python. That said, arbitrage betting is a distant cousin of the kind of work you might do in a high-frequency trading environment, where every millisecond counts. Usually, companies in this space use C++ or C# for their low-level systems, but I predict Rust will grow in popularity here, as it has done in many other domains where C++ is dominant.

Before we begin coding, let’s first understand what arbitrage betting is. (If you’re already comfortable with the concept, you can skip to the next section!)

What is Arbitrage Betting?

Arbitrage betting is a form of betting on sports outcomes where a win is guaranteed. We don’t need to know anything about the sport in question: playing the numbers correctly means that you always come out on top.

Usually, of course, it’s the bookmakers that come out on top, but occasionally they make mistakes. If we find such a mistake—an arbitrage opportunity—we can be on all possible outcomes at different bookmakers and we are guaranteed to make a profit.

For our program, that mathematics required will be fairly simple, but if you’re not mathematically inclined, I'll do my best to break it down.

As an example, we’ll use two fictional bookmakers: SportsLand and QuickBet. Both are offering odds on a tennis match between Novak Djokovic and Carlos Alcaraz.

An Example Scenario

SportsLand is offering odds of 1.8 for Djokovic to win, meaning that for every £1 we put in, we get £1.8 out if we win.

QuickBet is offering odds of 2.4 for Alcaraz to win, meaning that for every £1 we put in, we get £2.4 out if we win.

It may not be obvious yet, but this is an arbitrage opportunity.

If we put £100 on Djokovic to win and £100 on Alcaraz, what happens?

If Alcaraz wins, we make £240. We put in £200, so that’s a £40 profit. But if Djokovic wins, we only make £180—£20 less than the £200 we put in. A loss! But we can tweak the numbers to guarantee a profit.

Instead, let’s put £115 on Djokovic and £85 on Alcaraz. We’re still betting £200, but this time every outcome results in a profit.

If Alcaraz wins, we make £204. If Djokovic wins, we make £207. A profit is guaranteed!

Note that, if the odds were even slightly different, there would be no opportunity. If SportsLand’s odds on Djokovic winning were 1.7 instead of 1.8, there would be no way to guarantee profit.

We’ll build an app that helps us comb through data to identify these arbitrage opportunities and then calculates the stakes for us.

© 2025 Bret Cameron