Follow the Money: Which Constituencies Are Gamblers Interested In?

Nima Hamedani-Raja
My_Quantitative_Reveries
2 min readJun 27, 2024

Betting markets have been in the news for all the wrong reasons lately, but that’s not all they’re good for. They reflect the opinions of a subsection of the electorate who are politically savvy and willing to take risks.

Let’s start with a list of constituencies gamblers believe are worth a punt. To extract the data from Betfair, I used betfaiR (an R package which provides access to Betfair’s API). The code can be found at the bottom of this page as well as on GitHub.

As of today (Thursday, 27 June 2024), punters have staked a total of £489,028.08 on 650 markets on Betfair (one for each constituency), but the money is far from evenly distributed. Some constituencies are more equal than others.

Not a single bet has been matched for 119 constituencies, presumably because they are so one-sided that they are not worth a bet. Almost half of the constituencies (327 out of 650) have had less than £25 matched so far.

At the other end of the spectrum, the hottest 10 constituencies are responsible for 51.1% of the bets made (£250,060.40).

Here is a list of the top 20 hottest constituency markets:

Unsurprisingly, punters have shown a particular interest in important and/or controversial figures such as Nigel Farage, Jeremy Corbyn, Rishi Sunak, Daisy Cooper, Richard Tice, George Galloway, Sian Berry, Liam Fox, Liz Truss, Lee Anderson, and Damian Green. The list also includes constituencies where incumbent Conservatives with a sizeable majority are likely to lose their seats.

An interesting question, which I’ll explore in a separate post, is whether the ‘hotness’ of a particular betting market reflects the uncertainty in the outcome of the election in a constituency. Anecdotally, this seems to be the case, but I’d like to quantify it.

Update (01-July-2024)

total bets matched = £589028.70

Constituencies with less than £25 matched = 281 (95 of which 0)

Here is my code:

#### Installing and loading libraries ####

# devtools::install_github("durtal/betfaiR", force = TRUE)
options(stringsAsFactors = FALSE)
library(betfaiR)
library(dplyr)

#### Connecting to Betfair API ####

nima_login_data <-
read.csv("my_login_data.csv")

my_bf <- betfair(usr = nima_login_data$username,
pwd = nima_login_data$password,
key = as.character(nima_login_data$applicationKey))

#### get_and_save_a_market reads **a_market** name, gets its data from
#### betfair and saves the results in **folder**

get_and_save_a_market <- function(a_market, folder){

market_id <- a_market$raw$marketId
market_name <- gsub("/|\\?", "-", a_market$raw$marketName)
event_name <- gsub("/|\\?", "-", a_market$event$name)

MarketBook_raw <-
my_bf$marketBook(marketIds = market_id, getRunners = TRUE)

time <- Sys.time()

file_name <- paste(folder,
event_name,
"_",
market_name,
"_",
format(time, "%Y%m%d_%H%M%S"),
".rda",
sep = "")

print(file_name)

MarketBook <-
list(time = time,
Catalogue = a_market,
MarketBook = MarketBook_raw)

save(MarketBook, file = file_name)
}

#### Getting, cleaning and saving the results

all_politics_events <-
my_bf$events(filter = marketFilter(eventTypeIds = 2378961))

constituency_events <-
all_politics_events[grepl("UK - General Election",
all_politics_events$event_name),] %>%
select(event_id) %>% unlist() %>% as.numeric()

constituency_markets <-
my_bf$marketCatalogue(
maxResults = 1000,
filter = marketFilter(
eventIds = constituency_events
))


lapply(constituency_markets, get_and_save_a_market, "data/")

--

--