# Betting on Home Underdogs in Football

Published on April 7, 2020, 6:40 p.m. - Sports: Football

This is a very simple strategy where a back bet is placed on underdogs who are playing at home. A team qualifies as underdog when the odds for a win are higher compared to the opponent. Backtest is done for major football leagues in Europe but the strategy could also be applied to other sports.

I came across this strategy when reading bestbettingonline.com's guide on creating models. I like the article very much and quickly tried to replicate their backtesting result. The idea behind this strategy is pretty simple: You just go through all the football matches and check the winning odds of the teams. If the odds of the home team are larger compared to the away team, a back bet is placed on the home team as it is considered a underdog (less likely to win the game).

## Adapting the Python Backtesting Script

As the python script for the backtest was already provided, I just made some minor modifications: I replaced the csv package by pandas and included the download of the football data in the script:

``````
import pandas as pd

wagering_size = 5
starting_bankroll = 100

df["profit"] = df.apply(
lambda row: (wagering_size * (row["B365H"] -1) if
row["FTHG"] > row["FTAG"] else -wagering_size)
if row["B365H"] > row["B365A"] else 0,
axis=1
)
candidates = (df.profit != 0).sum()
bankroll = starting_bankroll + df.profit.sum()
ROI = (bankroll - starting_bankroll) / (wagering_size * candidates) * 100

print(f"There were '{(df.profit > 0).sum()}' upsets out of '{candidates}'")
print(f"Starting bankroll = '{starting_bankroll}'")
print(f"Finishing bankroll = '{bankroll}' | ROI = '{ROI}'")
``````

For the backtest Bet365 odds are used which are published on http://www.football-data.co.uk/data.php. For the Premier League season 2015/16 it returns a profit of 7.9 points for stake of 5 points per match. This is exactly the same result as published on bestbettingonline.com's website, hence I was confident that the script is working as expected and tried to do some more analysis.

## Looking at other Leagues and Seasons

There was a hint in the article to look at a bigger sample size. Hence I added to the backtesting script to include all the seasons starting from 2013/14 to 2018/19. I also looked at other European football leagues and included data for Germany, Italy and Spain.

The results are shown in the following table. This time I normalized the profits and used 1 point stake per match. The values in the table are the total profits per season and league.

Season England Germany Italy Spain
2013/14 -7.82 -1.37 -28.52 27.35
2014/15 1.41 11.21 -10.07 -30.26
2015/16 1.58 -4.31 -9.82 10.51
2016/17 2.45 27.03 -14.35 -8.65
2017/18 15.06 13.03 -50.48 2.38
2018/19 24.95 -4.91 -21.67 8.43

Putting Italy aside, this strategy would have resulted in positive returns over the past couple of seasons, at least for the football leagues in England, Germany and Spain.

## Backtest Result for the English Premier League

The following backtest shows the result for the English Premier League with a chart illustrating the cumulative profit, assuming a stake of 1 point per match:

## Create a Trading Bot to bet on Home Underdogs

It is rather simple to create a bot to automatically place bets on home underdogs. Although I used Bet365 odds data for the backtest I will rather describe how to create a betting bot for Betfair: Relevant markets can be fetched via listMarketCatalogue endpoint where filters can be added to select a certain eventType (e.g. football) and country (e.g. "GB"). Via competitionIds parameter you can narrow down the markets to certain leagues (e.g. Premier League) and also use the marketStartTime filter to only fetch matches which are about to start. In a next step you can then use the listMarketBook endpoint to fetch odds data and compare the odds for the teams to check if a bet should be placed. Which team is playing at home and away can be worked out from the event name. The bet can then be placed via placeOrders endpoint.