This report will try to state and visualize the performance of our current model in from the month the Start of the season until the January the 12th. And how tuning/filtering the matches that we invest on for the Optimum Odds is key in obtaining profit with our sports betting model.
The model that we will use will be model_favud_6.
decembertest.rdsis a dataframe consisting of all the matches from the start of the season untill Decemberr 1st 2019 (First Quarter).decembertest_2.rdsis a dataframe consisting of all the matches from December 1st 2019 until January 19th 2020 (Second Quarter).decembertest <- readRDS("decembertest.rds")
decembertest <- na.omit(decembertest)
modelforest.favud <- readRDS("model_favud_6.rds")
pred.favud.decembertest <- predict(modelforest.favud,decembertest,type = "prob")From our confusion matrix we can conclude that we have a general accuracy of 53.89%.
With a 52.95% win percentage from fav predicts, and 54.82% win percentage from our ud predicts.
#> Confusion Matrix and Statistics
#>
#> Reference
#> Prediction fav ud
#> fav 296 263
#> ud 253 307
#>
#> Accuracy : 0.5389
#> 95% CI : (0.5092, 0.5684)
#> No Information Rate : 0.5094
#> P-Value [Acc > NIR] : 0.02592
#>
#> Kappa : 0.0777
#>
#> Mcnemar's Test P-Value : 0.69196
#>
#> Sensitivity : 0.5392
#> Specificity : 0.5386
#> Pos Pred Value : 0.5295
#> Neg Pred Value : 0.5482
#> Prevalence : 0.4906
#> Detection Rate : 0.2645
#> Detection Prevalence : 0.4996
#> Balanced Accuracy : 0.5389
#>
#> 'Positive' Class : fav
#>
Below is the table consisting all the matches available to bet on in the first quarter of the Season.
hdp_return <- decembertest %>%
mutate(favchance = pred.favud.decembertest$fav,
pred = as.factor(ifelse(favchance>0.5,"fav","ud")),
win = ifelse(winner == pred,"W","L"),
favodds = ifelse(B365H<B365A,B365H,B365A),
udodds = ifelse(B365H<B365A,B365A,B365H),
earnings = ifelse(win == "W" & pred == "fav", favodds-1,
ifelse(win == "W" & pred == "ud" & FTR == "D",((B365D-1)/2)-0.5,
ifelse(win == "W" & pred == "ud" & FTR != "D",((udodds-1)/2)-0.5,-1)))) %>%
select(Date,Tier,League,HomeTeam,AwayTeam,favchance,favodds,pred,winner,win,earnings)
hdp_bankroll <- hdp_return %>%
group_by(Date) %>%
summarise(earnings = sum(earnings),
games = n()) %>%
mutate(bankroll = cumsum(earnings))
hdp_bankroll_month <- hdp_return %>%
mutate( wongames = ifelse(win == "W",1,0)) %>%
group_by(month = floor_date(Date,"month")) %>%
summarise(earnings = sum(earnings),
games = n(),
gameswon = sum(wongames)) %>%
mutate(winpct = round(gameswon*100/games,2),
bankroll = cumsum(earnings))
tail(hdp_return,80)With our 53.89% win rate, we are still recoding a loss of -61.31 units per the 12th of January.
The graph below shows the progress of our overall Bankroll/Financial Resource vs the time.
The problem,percentage of wins of our model, 53.89%, is still recording a loss over time in our bank loss. It seems as if we place all bets we are not obtaining the right value of the odds payout. To explain a little about value of odds, a simpler example is a coin toss. A coin toss provides a 50 50 chance for the outcome heads or tails. If we bet on heads, we should expect a breakeven payout at 2.00. This means everytime the outcome is Heads, we get 2.00 x bet unit. In the long run, statistically we will break even, no profit or loss.
But in the betting market, the house/bookie sets a commision for providing the bets. This usually ranges from 5-15%. This means, that the original payout of 2.00 becomes 0.95. Bookies also apply adjustments according to the supply and demand of their market. When the majority of his bettors places a bet on heads, he will have to lower the payout for heads and increase the tails payout in order to balance his banks and avoid losses.
So further on, the 0.95 can become 0.8 while the tails payout becomes 2.05. This is what we mean by value, in the long run, you will statistially record a profit because your chance is truly at 50% while your payout is at 2.05. Upon 100 coin tosses you will win 50 tosses, while obtaining a 2.5 units of profit.
To put it simply, what we are trying to accomplish is to see value in the market where everybody else doesn’t. In this case, the odds payout.
We optimize the odds for each possible type of bet, in order to maximize profit from the market.
temp <- NULL
temp1 <- NULL
temp2 <- NULL
temp3 <- NULL
for( x in 1:200){
hdp_return_high_2 <- decembertest %>%
mutate(favchance = pred.favud.decembertest$fav,
pred = as.factor(ifelse(favchance>0.5,"fav","ud")),
win = ifelse(winner == pred,"W","L"),
favodds = ifelse(B365H<B365A,B365H,B365A),
udodds = ifelse(B365H<B365A,B365A,B365H),
bettype = "fav A odds < opt_udhome2",
earnings = ifelse(win == "W" & pred == "fav", favodds-1,
ifelse(win == "W" & pred == "ud" & FTR == "D",((B365D-1)/2)-0.5,
ifelse(win == "W" & pred == "ud" & FTR != "D",((udodds-1)/2)-0.5,-1)))) %>%
select(Date,Tier,League,HomeTeam,AwayTeam,favchance,favodds,fav,pred,winner,win,earnings,bettype) %>%
filter(favchance < 0.5) %>%
filter(fav == "A") %>%
filter(favodds < (1+(x/100)))
hdp_bankroll_high_2 <- hdp_return_high_2 %>%
group_by(Date) %>%
summarise(earnings = sum(earnings)) %>%
mutate(bankroll = cumsum(earnings))
temp <- sum(hdp_bankroll_high_2$earnings)
temp2 <- nrow(hdp_return_high_2)
temp1 <- c(temp1,temp)
temp3 <- c(temp3,temp2)
}
temp1 <- cbind((1:200),temp1) %>%
as.data.frame() %>%
mutate(ngames = temp3,
ROI = temp1/ngames)
temp1 <- na.omit(temp1)
ggplot(temp1)+
geom_line(aes(x = V1 , y = temp1))#> [1] 3.575
#> [1] 121
#optimum value
hdp_return_high_2 <- decembertest %>%
mutate(favchance = pred.favud.decembertest$fav,
pred = as.factor(ifelse(favchance>0.5,"fav","ud")),
win = ifelse(winner == pred,"W","L"),
favodds = ifelse(B365H<B365A,B365H,B365A),
udodds = ifelse(B365H<B365A,B365A,B365H),
bettype = "UD home, fav odds < 1.5",
earnings = ifelse(win == "W" & pred == "fav", favodds-1,
ifelse(win == "W" & pred == "ud" & FTR == "D",((B365D-1)/2)-0.5,
ifelse(win == "W" & pred == "ud" & FTR != "D",((udodds-1)/2)-0.5,-1)))) %>%
select(Date,Tier,League,HomeTeam,AwayTeam,favchance,favodds,fav,pred,winner,win,earnings,bettype) %>%
filter(favchance < 0.5) %>%
filter(fav == "A") %>%
filter(favodds < (1+(opt_udhome2/100)))
hdp_bankroll_high_2 <- hdp_return_high_2 %>%
group_by(Date) %>%
summarise(earnings = sum(earnings)) %>%
mutate(bankroll = cumsum(earnings))
hdp_return_high_2#League Performance
by_leagues_2 <- hdp_return_high_2 %>%
mutate(wincount = ifelse(win == "W",1,0)) %>%
group_by(League) %>%
summarise(earnings = sum(earnings),
count = n(),
wincount = sum(wincount),
"win %" = round(wincount/count,2)*100) %>%
ungroup() %>%
arrange(desc(earnings))
by_leagues_2#>
#> L W
#> 0.4725275 0.5274725
temp <- NULL
temp1 <- NULL
temp2 <- NULL
temp3 <- NULL
for( x in 1:200){
hdp_return_high_5 <- decembertest %>%
mutate(favchance = pred.favud.decembertest$fav,
pred = as.factor(ifelse(favchance>0.5,"fav","ud")),
win = ifelse(winner == pred,"W","L"),
favodds = ifelse(B365H<B365A,B365H,B365A),
udodds = ifelse(B365H<B365A,B365A,B365H),
bettype = "UD Home, favodds > opt_udhome",
earnings = ifelse(win == "W" & pred == "fav", favodds-1,
ifelse(win == "W" & pred == "ud" & FTR == "D",((B365D-1)/2)-0.5,
ifelse(win == "W" & pred == "ud" & FTR != "D",((udodds-1)/2)-0.5,-1)))) %>%
select(Date,Tier,League,HomeTeam,AwayTeam,favchance,favodds,fav,pred,winner,win,earnings,bettype) %>%
filter(favodds > 1+(x/100)) %>%
filter(favchance < 0.5) %>%
filter(fav == "A")
hdp_bankroll_high_5 <- hdp_return_high_5 %>%
group_by(Date) %>%
summarise(earnings = sum(earnings)) %>%
mutate(bankroll = cumsum(earnings))
temp <- sum(hdp_bankroll_high_5$earnings)
temp2 <- nrow(hdp_return_high_5)
temp1 <- c(temp1,temp)
temp3 <- c(temp3,temp2)
}
temp1 <- cbind((1:200),temp1) %>%
as.data.frame() %>%
mutate(ngames = temp3,
ROI = temp1/ngames)
temp1 <- na.omit(temp1)
ggplot(temp1)+
geom_line(aes(x = V1 , y = temp1))#> [1] 7.215
#> [1] 145
#Optimum Value
hdp_return_high_5 <- decembertest %>%
mutate(favchance = pred.favud.decembertest$fav,
pred = as.factor(ifelse(favchance>0.5,"fav","ud")),
win = ifelse(winner == pred,"W","L"),
favodds = ifelse(B365H<B365A,B365H,B365A),
udodds = ifelse(B365H<B365A,B365A,B365H),
bettype = "UD Home, favodds > 2.45",
earnings = ifelse(win == "W" & pred == "fav", favodds-1,
ifelse(win == "W" & pred == "ud" & FTR == "D",((B365D-1)/2)-0.5,
ifelse(win == "W" & pred == "ud" & FTR != "D",((udodds-1)/2)-0.5,-1)))) %>%
select(Date,Tier,League,HomeTeam,AwayTeam,favchance,favodds,fav,pred,winner,win,earnings,bettype) %>%
filter(favodds > 1+(opt_udhome/100)) %>%
filter(favchance < 0.5) %>%
filter(fav == "A")
hdp_bankroll_high_5 <- hdp_return_high_5 %>%
group_by(Date) %>%
summarise(earnings = sum(earnings)) %>%
mutate(bankroll = cumsum(earnings))
hdp_return_high_5#>
#> L W
#> 0.2372881 0.7627119
#League Performance
by_leagues_5 <- hdp_return_high_5 %>%
mutate(wincount = ifelse(win == "W",1,0)) %>%
group_by(League) %>%
summarise(earnings = sum(earnings),
count = n(),
wincount = sum(wincount),
"win %" = round(wincount/count,2)*100) %>%
ungroup() %>%
arrange(desc(earnings))
by_leagues_5temp <- NULL
temp1 <- NULL
temp2 <- NULL
temp3 <- NULL
for( x in 1:200){
hdp_return_high_3 <- decembertest %>%
mutate(favchance = pred.favud.decembertest$fav,
pred = as.factor(ifelse(favchance>0.5,"fav","ud")),
win = ifelse(winner == pred,"W","L"),
favodds = ifelse(B365H<B365A,B365H,B365A),
udodds = ifelse(B365H<B365A,B365A,B365H),
bettype = "Fav Home, favodds > opt_favhome",
earnings = ifelse(win == "W" & pred == "fav", favodds-1,
ifelse(win == "W" & pred == "ud" & FTR == "D",((B365D-1)/2)-0.5,
ifelse(win == "W" & pred == "ud" & FTR != "D",((udodds-1)/2)-0.5,-1)))) %>%
select(Date,Tier,League,HomeTeam,AwayTeam,favchance,favodds,fav,pred,winner,win,earnings,bettype) %>%
filter(favodds > (1+(x/100))) %>%
filter(favchance >0.5) %>%
filter(favchance < 0.75) %>%
filter(fav == "H")
hdp_bankroll_high_3 <- hdp_return_high_3 %>%
group_by(Date) %>%
summarise(earnings = sum(earnings)) %>%
mutate(bankroll = cumsum(earnings))
temp <- sum(hdp_bankroll_high_3$earnings)
temp2 <- nrow(hdp_return_high_3)
temp1 <- c(temp1,temp)
temp3 <- c(temp3,temp2)
}
temp1 <- cbind((1:200),temp1) %>%
as.data.frame() %>%
mutate(ngames = temp3,
ROI = temp1/ngames)
temp1 <- na.omit(temp1)
ggplot(temp1)+
geom_line(aes(x = V1 , y = temp1))#> [1] 1.7
#> [1] 162
#Optimum Value
hdp_return_high_3 <- decembertest %>%
mutate(favchance = pred.favud.decembertest$fav,
pred = as.factor(ifelse(favchance>0.5,"fav","ud")),
win = ifelse(winner == pred,"W","L"),
favodds = ifelse(B365H<B365A,B365H,B365A),
udodds = ifelse(B365H<B365A,B365A,B365H),
bettype = "Fav Home, favodds > 2.37",
earnings = ifelse(win == "W" & pred == "fav", favodds-1,
ifelse(win == "W" & pred == "ud" & FTR == "D",((B365D-1)/2)-0.5,
ifelse(win == "W" & pred == "ud" & FTR != "D",((udodds-1)/2)-0.5,-1)))) %>%
select(Date,Tier,League,HomeTeam,AwayTeam,favchance,favodds,fav,pred,winner,win,earnings,bettype) %>%
filter(favodds > (1+(opt_favhome/100))) %>%
filter(favchance >0.5) %>%
filter(favchance < 0.75) %>%
filter(fav == "H")
hdp_bankroll_high_3 <- hdp_return_high_3 %>%
group_by(Date) %>%
summarise(earnings = sum(earnings)) %>%
mutate(bankroll = cumsum(earnings))
hdp_return_high_3ggplot(hdp_bankroll_high_3)+
geom_line(aes(x = Date, y = bankroll))+
geom_point(aes(x = Date, y = bankroll))+
labs(y = "Progression of Bankroll in (Units)")#League Performance
by_leagues_3 <- hdp_return_high_3 %>%
mutate(wincount = ifelse(win == "W",1,0)) %>%
group_by(League) %>%
summarise(earnings = sum(earnings),
count = n(),
wincount = sum(wincount),
"win %" = round(wincount/count,2)*100) %>%
ungroup() %>%
arrange(desc(earnings))
by_leagues_3#>
#> W
#> 1
temp <- NULL
temp1 <- NULL
temp2 <- NULL
temp3 <- NULL
for( x in 1:200){
hdp_return_high_9 <- decembertest %>%
mutate(favchance = pred.favud.decembertest$fav,
pred = as.factor(ifelse(favchance>0.5,"fav","ud")),
win = ifelse(winner == pred,"W","L"),
favodds = ifelse(B365H<B365A,B365H,B365A),
udodds = ifelse(B365H<B365A,B365A,B365H),
bettype = "Fav Home, favodds < opt_favhome2",
earnings = ifelse(win == "W" & pred == "fav", favodds-1,
ifelse(win == "W" & pred == "ud" & FTR == "D",((B365D-1)/2)-0.5,
ifelse(win == "W" & pred == "ud" & FTR != "D",((udodds-1)/2)-0.5,-1)))) %>%
select(Date,Tier,League,HomeTeam,AwayTeam,favchance,favodds,fav,pred,winner,win,earnings,bettype) %>%
filter(favodds < (1+(x/100))) %>%
filter(favchance >0.5) %>%
filter(favchance < 0.75) %>%
filter(fav == "H")
hdp_bankroll_high_3 <- hdp_return_high_9 %>%
group_by(Date) %>%
summarise(earnings = sum(earnings)) %>%
mutate(bankroll = cumsum(earnings))
temp <- sum(hdp_bankroll_high_3$earnings)
temp2 <- nrow(hdp_return_high_9)
temp1 <- c(temp1,temp)
temp3 <- c(temp3,temp2)
}
temp1 <- cbind((1:200),temp1) %>%
as.data.frame() %>%
mutate(ngames = temp3,
ROI = temp1/ngames)
temp1 <- na.omit(temp1)
ggplot(temp1)+
geom_line(aes(x = V1 , y = temp1))#> [1] 0.085
#> [1] 11
#Optimum Value
hdp_return_high_9 <- decembertest %>%
mutate(favchance = pred.favud.decembertest$fav,
pred = as.factor(ifelse(favchance>0.5,"fav","ud")),
win = ifelse(winner == pred,"W","L"),
favodds = ifelse(B365H<B365A,B365H,B365A),
udodds = ifelse(B365H<B365A,B365A,B365H),
bettype = "Fav Home, favodds < 1.11",
earnings = ifelse(win == "W" & pred == "fav", favodds-1,
ifelse(win == "W" & pred == "ud" & FTR == "D",((B365D-1)/2)-0.5,
ifelse(win == "W" & pred == "ud" & FTR != "D",((udodds-1)/2)-0.5,-1)))) %>%
select(Date,Tier,League,HomeTeam,AwayTeam,favchance,favodds,fav,pred,winner,win,earnings,bettype) %>%
filter(favodds < (1+(opt_favhome2/100))) %>%
filter(favchance >0.5) %>%
filter(favchance < 0.75) %>%
filter(fav == "H")
hdp_bankroll_high_9 <- hdp_return_high_9 %>%
group_by(Date) %>%
summarise(earnings = sum(earnings)) %>%
mutate(bankroll = cumsum(earnings))
hdp_return_high_9ggplot(hdp_bankroll_high_9)+
geom_line(aes(x = Date, y = bankroll))+
geom_point(aes(x = Date, y = bankroll))+
labs(y = "Progression of Bankroll in (Units)")#League Performance
by_leagues_9 <- hdp_return_high_9 %>%
mutate(wincount = ifelse(win == "W",1,0)) %>%
group_by(League) %>%
summarise(earnings = sum(earnings),
count = n(),
wincount = sum(wincount),
"win %" = round(wincount/count,2)*100) %>%
ungroup() %>%
arrange(desc(earnings))
by_leagues_9#>
#> W
#> 1
temp <- NULL
temp1 <- NULL
temp2 <- NULL
temp3 <- NULL
for( x in 1:200){
hdp_return_high_4 <- decembertest %>%
mutate(favchance = pred.favud.decembertest$fav,
pred = as.factor(ifelse(favchance>0.5,"fav","ud")),
win = ifelse(winner == pred,"W","L"),
favodds = ifelse(B365H<B365A,B365H,B365A),
udodds = ifelse(B365H<B365A,B365A,B365H),
bettype = "UD away, favodds < opt_udaway2",
earnings = ifelse(win == "W" & pred == "fav", favodds-1,
ifelse(win == "W" & pred == "ud" & FTR == "D",((B365D-1)/2)-0.5,
ifelse(win == "W" & pred == "ud" & FTR != "D",((udodds-1)/2)-0.5,-1)))) %>%
select(Date,Tier,League,HomeTeam,AwayTeam,favchance,favodds,fav,pred,winner,win,earnings,bettype) %>%
filter(favodds < (1+(x/100))) %>%
filter(favchance < 0.5) %>%
filter(fav == "H")
hdp_bankroll_high_4 <- hdp_return_high_4 %>%
group_by(Date) %>%
summarise(earnings = sum(earnings)) %>%
mutate(bankroll = cumsum(earnings))
temp <- sum(hdp_bankroll_high_4$earnings)
temp2 <- nrow(hdp_return_high_4)
temp1 <- c(temp1,temp)
temp3 <- c(temp3,temp2)
}
temp1 <- cbind((1:200),temp1) %>%
as.data.frame() %>%
mutate(ngames = temp3,
ROI = temp1/ngames)
temp1 <- na.omit(temp1)
ggplot(temp1)+
geom_line(aes(x = V1 , y = temp1))#> [1] 0.07736486
#> [1] 81
#Optimum Value
hdp_return_high_4 <- decembertest %>%
mutate(favchance = pred.favud.decembertest$fav,
pred = as.factor(ifelse(favchance>0.5,"fav","ud")),
win = ifelse(winner == pred,"W","L"),
favodds = ifelse(B365H<B365A,B365H,B365A),
udodds = ifelse(B365H<B365A,B365A,B365H),
bettype = "UD away, favodds < 1.85",
earnings = ifelse(win == "W" & pred == "fav", favodds-1,
ifelse(win == "W" & pred == "ud" & FTR == "D",((B365D-1)/2)-0.5,
ifelse(win == "W" & pred == "ud" & FTR != "D",((udodds-1)/2)-0.5,-1)))) %>%
select(Date,Tier,League,HomeTeam,AwayTeam,favchance,favodds,fav,pred,winner,win,earnings,bettype) %>%
filter(favodds < (1+(opt_udaway2/100))) %>%
filter(favchance < 0.5) %>%
filter(fav == "H")
hdp_bankroll_high_4 <- hdp_return_high_4 %>%
group_by(Date) %>%
summarise(earnings = sum(earnings)) %>%
mutate(bankroll = cumsum(earnings))
hdp_return_high_4#>
#> L W
#> 0.5 0.5
ggplot(hdp_bankroll_high_4)+
geom_line(aes(x = Date, y = bankroll))+
labs(y = "Progression of Bankroll in (Units)")#League Performance
by_leagues_4 <- hdp_return_high_4 %>%
mutate(wincount = ifelse(win == "W",1,0)) %>%
group_by(League) %>%
summarise(earnings = sum(earnings),
count = n(),
wincount = sum(wincount),
"win %" = round(wincount/count,2)*100) %>%
ungroup() %>%
arrange(desc(earnings))
by_leagues_4temp <- NULL
temp1 <- NULL
temp2 <- NULL
temp3 <- NULL
for( x in 1:200){
hdp_return_high_7 <- decembertest %>%
mutate(favchance = pred.favud.decembertest$fav,
pred = as.factor(ifelse(favchance>0.5,"fav","ud")),
win = ifelse(winner == pred,"W","L"),
favodds = ifelse(B365H<B365A,B365H,B365A),
udodds = ifelse(B365H<B365A,B365A,B365H),
bettype = "UD away, favodds > opt_udaway",
earnings = ifelse(win == "W" & pred == "fav", favodds-1,
ifelse(win == "W" & pred == "ud" & FTR == "D",((B365D-1)/2)-0.5,
ifelse(win == "W" & pred == "ud" & FTR != "D",((udodds-1)/2)-0.5,-1)))) %>%
select(Date,Tier,League,HomeTeam,AwayTeam,favchance,favodds,fav,pred,winner,win,earnings,bettype) %>%
filter(favodds > (1+(x/100))) %>%
filter(favchance < 0.5) %>%
filter(fav == "H")
hdp_bankroll_high_4 <- hdp_return_high_7 %>%
group_by(Date) %>%
summarise(earnings = sum(earnings)) %>%
mutate(bankroll = cumsum(earnings))
temp <- sum(hdp_bankroll_high_4$earnings)
temp2 <- nrow(hdp_return_high_7)
temp1 <- c(temp1,temp)
temp3 <- c(temp3,temp2)
}
temp1 <- cbind((1:200),temp1) %>%
as.data.frame() %>%
mutate(ngames = temp3,
ROI = temp1/ngames)
temp1 <- na.omit(temp1)
ggplot(temp1)+
geom_line(aes(x = V1 , y = temp1))#> [1] 0.45
#> [1] 175
#Optimum Value
hdp_return_high_7 <- decembertest %>%
mutate(favchance = pred.favud.decembertest$fav,
pred = as.factor(ifelse(favchance>0.5,"fav","ud")),
win = ifelse(winner == pred,"W","L"),
favodds = ifelse(B365H<B365A,B365H,B365A),
udodds = ifelse(B365H<B365A,B365A,B365H),
bettype = "UD away, favodds > 2.6",
earnings = ifelse(win == "W" & pred == "fav", favodds-1,
ifelse(win == "W" & pred == "ud" & FTR == "D",((B365D-1)/2)-0.5,
ifelse(win == "W" & pred == "ud" & FTR != "D",((udodds-1)/2)-0.5,-1)))) %>%
select(Date,Tier,League,HomeTeam,AwayTeam,favchance,favodds,fav,pred,winner,win,earnings,bettype) %>%
filter(favodds > (1+(opt_udaway/100))) %>%
filter(favchance < 0.5) %>%
filter(fav == "H")
hdp_bankroll_high_7 <- hdp_return_high_7 %>%
group_by(Date) %>%
summarise(earnings = sum(earnings)) %>%
mutate(bankroll = cumsum(earnings))
hdp_return_high_7#>
#> W
#> 1
ggplot(hdp_bankroll_high_7)+
geom_line(aes(x = Date, y = bankroll))+
labs(y = "Progression of Bankroll in (Units)")#League Performance
by_leagues_7 <- hdp_return_high_7 %>%
mutate(wincount = ifelse(win == "W",1,0)) %>%
group_by(League) %>%
summarise(earnings = sum(earnings),
count = n(),
wincount = sum(wincount),
"win %" = round(wincount/count,2)*100) %>%
ungroup() %>%
arrange(desc(earnings))
by_leagues_7temp <- NULL
temp1 <- NULL
temp2 <- NULL
temp3 <- NULL
for( x in 1:200){
hdp_return_high_6 <- decembertest %>%
mutate(favchance = pred.favud.decembertest$fav,
pred = as.factor(ifelse(favchance>0.5,"fav","ud")),
win = ifelse(winner == pred,"W","L"),
favodds = ifelse(B365H<B365A,B365H,B365A),
udodds = ifelse(B365H<B365A,B365A,B365H),
bettype = "Fav Away, favodds < opt_favaway2",
earnings = ifelse(win == "W" & pred == "fav", favodds-1,
ifelse(win == "W" & pred == "ud" & FTR == "D",((B365D-1)/2)-0.5,
ifelse(win == "W" & pred == "ud" & FTR != "D",((udodds-1)/2)-0.5,-1)))) %>%
select(Date,Tier,League,HomeTeam,AwayTeam,favchance,favodds,fav,pred,winner,win,earnings,bettype) %>%
filter(favodds < (1+(x/100))) %>%
filter(favchance > 0.5) %>%
filter(fav == "A")
hdp_bankroll_high_6 <- hdp_return_high_6 %>%
group_by(Date) %>%
summarise(earnings = sum(earnings)) %>%
mutate(bankroll = cumsum(earnings))
temp <- sum(hdp_bankroll_high_6$earnings)
temp2 <- nrow(hdp_return_high_6)
temp1 <- c(temp1,temp)
temp3 <- c(temp3,temp2)
}
temp1 <- cbind((1:200),temp1) %>%
as.data.frame() %>%
mutate(ngames = temp3,
ROI = temp1/ngames)
temp1 <- na.omit(temp1)
ggplot(temp1)+
geom_line(aes(x = V1 , y = temp1))#> [1] 0.14
#> [1] 176
#Optimum Value
hdp_return_high_6 <- decembertest %>%
mutate(favchance = pred.favud.decembertest$fav,
pred = as.factor(ifelse(favchance>0.5,"fav","ud")),
win = ifelse(winner == pred,"W","L"),
favodds = ifelse(B365H<B365A,B365H,B365A),
udodds = ifelse(B365H<B365A,B365A,B365H),
bettype = "Fav Away, favodds < 3",
earnings = ifelse(win == "W" & pred == "fav", favodds-1,
ifelse(win == "W" & pred == "ud" & FTR == "D",((B365D-1)/2)-0.5,
ifelse(win == "W" & pred == "ud" & FTR != "D",((udodds-1)/2)-0.5,-1)))) %>%
select(Date,Tier,League,HomeTeam,AwayTeam,favchance,favodds,fav,pred,winner,win,earnings,bettype) %>%
filter(favodds < (1+(opt_favaway2/100))) %>%
filter(favchance > 0.5) %>%
filter(fav == "A")
hdp_bankroll_high_6 <- hdp_return_high_6 %>%
group_by(Date) %>%
summarise(earnings = sum(earnings)) %>%
mutate(bankroll = cumsum(earnings))
hdp_return_high_6#>
#> L W
#> 0.4150943 0.5849057
ggplot(hdp_bankroll_high_6)+
geom_line(aes(x = Date, y = bankroll))+
labs(y = "Progression of Bankroll in (Units)")#League Performance
by_leagues_6 <- hdp_return_high_6 %>%
mutate(wincount = ifelse(win == "W",1,0)) %>%
group_by(League) %>%
summarise(earnings = sum(earnings),
count = n(),
wincount = sum(wincount),
"win %" = round(wincount/count,2)*100) %>%
ungroup() %>%
arrange(desc(earnings))
by_leagues_6temp <- NULL
temp1 <- NULL
temp2 <- NULL
temp3 <- NULL
for( x in 1:200){
hdp_return_high_10 <- decembertest %>%
mutate(favchance = pred.favud.decembertest$fav,
pred = as.factor(ifelse(favchance>0.5,"fav","ud")),
win = ifelse(winner == pred,"W","L"),
favodds = ifelse(B365H<B365A,B365H,B365A),
udodds = ifelse(B365H<B365A,B365A,B365H),
bettype = "Fav away > opt_favaway",
earnings = ifelse(win == "W" & pred == "fav", favodds-1,
ifelse(win == "W" & pred == "ud" & FTR == "D",((B365D-1)/2)-0.5,
ifelse(win == "W" & pred == "ud" & FTR != "D",((udodds-1)/2)-0.5,-1)))) %>%
select(Date,Tier,League,HomeTeam,AwayTeam,favchance,favodds,fav,pred,winner,win,earnings,bettype) %>%
filter(favodds > (1+(x/100))) %>%
filter(favchance > 0.5) %>%
filter(fav == "A")
hdp_bankroll_high_10 <- hdp_return_high_10 %>%
group_by(Date) %>%
summarise(earnings = sum(earnings)) %>%
mutate(bankroll = cumsum(earnings))
temp <- sum(hdp_bankroll_high_10$earnings)
temp2 <- nrow(hdp_return_high_10)
temp1 <- c(temp1,temp)
temp3 <- c(temp3,temp2)
}
temp1 <- cbind((1:200),temp1) %>%
as.data.frame() %>%
mutate(ngames = temp3,
ROI = temp1/ngames)
temp1 <- na.omit(temp1)
ggplot(temp1)+
geom_line(aes(x = V1 , y = temp1))#> [1] 0.8333333
#> [1] 30
#Optimum Value
hdp_return_high_10 <- decembertest %>%
mutate(favchance = pred.favud.decembertest$fav,
pred = as.factor(ifelse(favchance>0.5,"fav","ud")),
win = ifelse(winner == pred,"W","L"),
favodds = ifelse(B365H<B365A,B365H,B365A),
udodds = ifelse(B365H<B365A,B365A,B365H),
bettype = "Fav Away, favodds < 3",
earnings = ifelse(win == "W" & pred == "fav", favodds-1,
ifelse(win == "W" & pred == "ud" & FTR == "D",((B365D-1)/2)-0.5,
ifelse(win == "W" & pred == "ud" & FTR != "D",((udodds-1)/2)-0.5,-1)))) %>%
select(Date,Tier,League,HomeTeam,AwayTeam,favchance,favodds,fav,pred,winner,win,earnings,bettype) %>%
filter(favodds > (1+(opt_favaway2/100))) %>%
filter(favchance > 0.5) %>%
filter(fav == "A")
hdp_bankroll_high_10 <- hdp_return_high_10 %>%
group_by(Date) %>%
summarise(earnings = sum(earnings)) %>%
mutate(bankroll = cumsum(earnings))
hdp_return_high_10#> numeric(0)
ggplot(hdp_bankroll_high_10)+
geom_line(aes(x = Date, y = bankroll))+
labs(y = "Progression of Bankroll in (Units)")#League Performance
by_leagues_10 <- hdp_return_high_10 %>%
mutate(wincount = ifelse(win == "W",1,0)) %>%
group_by(League) %>%
summarise(earnings = sum(earnings),
count = n(),
wincount = sum(wincount),
"win %" = round(wincount/count,2)*100) %>%
ungroup() %>%
arrange(desc(earnings))
by_leagues_10total_hdp_return <- rbind(hdp_return_high_3,
hdp_return_high_2,
hdp_return_high_4,
hdp_return_high_5,
hdp_return_high_6,
hdp_return_high_7,
hdp_return_high_9)
total_hdp_return <- distinct(total_hdp_return)
total_hdp_bankroll <- total_hdp_return %>%
group_by(Date) %>%
summarise(earnings = sum(earnings),
games = n()) %>%
mutate(bankroll = cumsum(earnings))
total_hdp_return %>%
arrange(Date)#>
#> L W
#> 0.4107143 0.5892857
#by league
bybettype <- total_hdp_return %>%
mutate(wincount = ifelse(win == "W",1,0)) %>%
group_by(bettype) %>%
summarise(earnings = sum(earnings),
count = n(),
wincount = sum(wincount),
"win %" = round(wincount/count,2)*100) %>%
ungroup() %>%
arrange(desc(earnings))
ggplot(total_hdp_bankroll)+
geom_line(aes(x = Date, y = bankroll))+
geom_point(aes(x = Date, y = bankroll))+
labs(y = "Progression of Bankroll in (Units)") ggplot(bybettype)+
geom_col(aes(x = reorder(bettype,earnings), y = earnings, fill = bettype))+
coord_flip()#> [1] 0.09727679
decembertest2 <- readRDS("decembertest_2.rds")
decembertest2 <- na.omit(decembertest2)
pred.favud.decembertest2 <- predict(modelforest.favud,decembertest2,type = "prob")#> Confusion Matrix and Statistics
#>
#> Reference
#> Prediction fav ud
#> fav 202 157
#> ud 127 167
#>
#> Accuracy : 0.5651
#> 95% CI : (0.5261, 0.6035)
#> No Information Rate : 0.5038
#> P-Value [Acc > NIR] : 0.0009812
#>
#> Kappa : 0.1295
#>
#> Mcnemar's Test P-Value : 0.0852811
#>
#> Sensitivity : 0.6140
#> Specificity : 0.5154
#> Pos Pred Value : 0.5627
#> Neg Pred Value : 0.5680
#> Prevalence : 0.5038
#> Detection Rate : 0.3093
#> Detection Prevalence : 0.5498
#> Balanced Accuracy : 0.5647
#>
#> 'Positive' Class : fav
#>
hdp_return <- decembertest2 %>%
mutate(favchance = pred.favud.decembertest2$fav,
pred = as.factor(ifelse(favchance>0.5,"fav","ud")),
win = ifelse(winner == pred,"W","L"),
favodds = ifelse(B365H<B365A,B365H,B365A),
udodds = ifelse(B365H<B365A,B365A,B365H),
earnings = ifelse(win == "W" & pred == "fav", favodds-1,
ifelse(win == "W" & pred == "ud" & FTR == "D",((B365D-1)/2)-0.5,
ifelse(win == "W" & pred == "ud" & FTR != "D",((udodds-1)/2)-0.5,-1)))) %>%
select(Date,Tier,League,HomeTeam,AwayTeam,favchance,favodds,pred,winner,win,earnings)
hdp_bankroll <- hdp_return %>%
group_by(Date) %>%
summarise(earnings = sum(earnings),
games = n()) %>%
mutate(bankroll = cumsum(earnings))
hdp_bankroll_month <- hdp_return %>%
mutate( wongames = ifelse(win == "W",1,0)) %>%
group_by(month = floor_date(Date,"month")) %>%
summarise(earnings = sum(earnings),
games = n(),
gameswon = sum(wongames)) %>%
mutate(winpct = round(gameswon*100/games,2),
bankroll = cumsum(earnings))
tail(hdp_return,80)With our 56.51% win rate, we are still recording a profit of 3.635 units per the 19th of January. This is without filtering the matches to our optimum value parameters. We hope with applying the odds parameters, we can hopefully reach a higher profit.
ggplot(hdp_bankroll)+
geom_line(aes(x = Date, y = bankroll))+
labs(y = "Progression of Bankroll in (Units)")#optimum value
hdp_return_high_2 <- decembertest2 %>%
mutate(favchance = pred.favud.decembertest2$fav,
pred = as.factor(ifelse(favchance>0.5,"fav","ud")),
win = ifelse(winner == pred,"W","L"),
favodds = ifelse(B365H<B365A,B365H,B365A),
udodds = ifelse(B365H<B365A,B365A,B365H),
bettype = "UD home , fav odds < 2.21",
earnings = ifelse(win == "W" & pred == "fav", favodds-1,
ifelse(win == "W" & pred == "ud" & FTR == "D",((B365D-1)/2)-0.5,
ifelse(win == "W" & pred == "ud" & FTR != "D",((udodds-1)/2)-0.5,-1)))) %>%
select(Date,Tier,League,HomeTeam,AwayTeam,favchance,favodds,fav,pred,winner,win,earnings,bettype) %>%
filter(favchance < 0.5) %>%
filter(fav == "A") %>%
filter(favodds < (1+(opt_udhome2/100)))
hdp_bankroll_high_2 <- hdp_return_high_2 %>%
group_by(Date) %>%
summarise(earnings = sum(earnings)) %>%
mutate(bankroll = cumsum(earnings))
hdp_return_high_2ggplot(hdp_bankroll_high_2)+
geom_line(aes(x = Date, y = bankroll))+
labs(y = "Progression of Bankroll in (Units)")#League Performance
by_leagues_2 <- hdp_return_high_2 %>%
mutate(wincount = ifelse(win == "W",1,0)) %>%
group_by(League) %>%
summarise(earnings = sum(earnings),
count = n(),
wincount = sum(wincount),
"win %" = round(wincount/count,2)*100) %>%
ungroup() %>%
arrange(desc(earnings))
by_leagues_2#>
#> L W
#> 0.4464286 0.5535714
#Optimum Value
hdp_return_high_3 <- decembertest2 %>%
mutate(favchance = pred.favud.decembertest2$fav,
pred = as.factor(ifelse(favchance>0.5,"fav","ud")),
win = ifelse(winner == pred,"W","L"),
favodds = ifelse(B365H<B365A,B365H,B365A),
udodds = ifelse(B365H<B365A,B365A,B365H),
bettype = "Fav Home, favodds > 2.62",
earnings = ifelse(win == "W" & pred == "fav", favodds-1,
ifelse(win == "W" & pred == "ud" & FTR == "D",((B365D-1)/2)-0.5,
ifelse(win == "W" & pred == "ud" & FTR != "D",((udodds-1)/2)-0.5,-1)))) %>%
select(Date,Tier,League,HomeTeam,AwayTeam,favchance,favodds,fav,pred,winner,win,earnings,bettype) %>%
filter(favodds > (1+(opt_favhome/100))) %>%
filter(favchance >0.5) %>%
filter(favchance < 0.75) %>%
filter(fav == "H")
hdp_bankroll_high_3 <- hdp_return_high_3 %>%
group_by(Date) %>%
summarise(earnings = sum(earnings)) %>%
mutate(bankroll = cumsum(earnings))
hdp_return_high_3ggplot(hdp_bankroll_high_3)+
geom_line(aes(x = Date, y = bankroll))+
geom_point(aes(x = Date, y = bankroll))+
labs(y = "Progression of Bankroll in (Units)")#League Performance
by_leagues_3 <- hdp_return_high_3 %>%
mutate(wincount = ifelse(win == "W",1,0)) %>%
group_by(League) %>%
summarise(earnings = sum(earnings),
count = n(),
wincount = sum(wincount),
"win %" = round(wincount/count,2)*100) %>%
ungroup() %>%
arrange(desc(earnings))
by_leagues_3#>
#> L
#> 1
#Optimum Value
hdp_return_high_4 <- decembertest2 %>%
mutate(favchance = pred.favud.decembertest2$fav,
pred = as.factor(ifelse(favchance>0.5,"fav","ud")),
win = ifelse(winner == pred,"W","L"),
favodds = ifelse(B365H<B365A,B365H,B365A),
udodds = ifelse(B365H<B365A,B365A,B365H),
bettype = "UD away, favodds < 1.81",
earnings = ifelse(win == "W" & pred == "fav", favodds-1,
ifelse(win == "W" & pred == "ud" & FTR == "D",((B365D-1)/2)-0.5,
ifelse(win == "W" & pred == "ud" & FTR != "D",((udodds-1)/2)-0.5,-1)))) %>%
select(Date,Tier,League,HomeTeam,AwayTeam,favchance,favodds,fav,pred,winner,win,earnings,bettype) %>%
filter(favodds < (1+(opt_udaway2/100))) %>%
filter(favchance < 0.5) %>%
filter(fav == "H")
hdp_bankroll_high_4 <- hdp_return_high_4 %>%
group_by(Date) %>%
summarise(earnings = sum(earnings)) %>%
mutate(bankroll = cumsum(earnings))
hdp_return_high_4#>
#> L W
#> 0.4324324 0.5675676
ggplot(hdp_bankroll_high_4)+
geom_line(aes(x = Date, y = bankroll))+
labs(y = "Progression of Bankroll in (Units)")#League Performance
by_leagues_4 <- hdp_return_high_4 %>%
mutate(wincount = ifelse(win == "W",1,0)) %>%
group_by(League) %>%
summarise(earnings = sum(earnings),
count = n(),
wincount = sum(wincount),
"win %" = round(wincount/count,2)*100) %>%
ungroup() %>%
arrange(desc(earnings))
by_leagues_4#Optimum Value
hdp_return_high_6 <- decembertest2 %>%
mutate(favchance = pred.favud.decembertest2$fav,
pred = as.factor(ifelse(favchance>0.5,"fav","ud")),
win = ifelse(winner == pred,"W","L"),
favodds = ifelse(B365H<B365A,B365H,B365A),
udodds = ifelse(B365H<B365A,B365A,B365H),
bettype = "Fav Away, favodds < 1.3",
earnings = ifelse(win == "W" & pred == "fav", favodds-1,
ifelse(win == "W" & pred == "ud" & FTR == "D",((B365D-1)/2)-0.5,
ifelse(win == "W" & pred == "ud" & FTR != "D",((udodds-1)/2)-0.5,-1)))) %>%
select(Date,Tier,League,HomeTeam,AwayTeam,favchance,favodds,fav,pred,winner,win,earnings,bettype) %>%
filter(favodds > (1+(opt_favaway/100))) %>%
filter(favchance > 0.5) %>%
filter(fav == "A")
hdp_bankroll_high_6 <- hdp_return_high_6 %>%
group_by(Date) %>%
summarise(earnings = sum(earnings)) %>%
mutate(bankroll = cumsum(earnings))
hdp_return_high_6#>
#> L W
#> 0.5063291 0.4936709
ggplot(hdp_bankroll_high_6)+
geom_line(aes(x = Date, y = bankroll))+
labs(y = "Progression of Bankroll in (Units)")#League Performance
by_leagues_6 <- hdp_return_high_6 %>%
mutate(wincount = ifelse(win == "W",1,0)) %>%
group_by(League) %>%
summarise(earnings = sum(earnings),
count = n(),
wincount = sum(wincount),
"win %" = round(wincount/count,2)*100) %>%
ungroup() %>%
arrange(desc(earnings))
by_leagues_6total_hdp_return <- rbind(hdp_return_high_2,
hdp_return_high_3,
hdp_return_high_4,
hdp_return_high_6)
total_hdp_return <- distinct(total_hdp_return)
saveRDS(total_hdp_return, "results2.rds")
total_hdp_bankroll <- total_hdp_return %>%
group_by(Date) %>%
summarise(earnings = sum(earnings),
games = n()) %>%
mutate(bankroll = cumsum(earnings))
total_hdp_return %>%
arrange(Date) %>%
select(-Tier)#>
#> L W
#> 0.4739884 0.5260116
#by league
bybettype <- total_hdp_return %>%
mutate(wincount = ifelse(win == "W",1,0)) %>%
group_by(bettype) %>%
summarise(earnings = sum(earnings),
count = n(),
wincount = sum(wincount),
"win %" = round(wincount/count,2)*100) %>%
ungroup() %>%
arrange(desc(earnings))
ggplot(total_hdp_bankroll)+
geom_line(aes(x = Date, y = bankroll))+
geom_point(aes(x = Date, y = bankroll))+
labs(y = "Progression of Bankroll in (Units)") ggplot(bybettype)+
geom_col(aes(x = reorder(bettype,earnings), y = earnings, fill = bettype))+
coord_flip()#> [1] 0.1324566
Our return on investment if we decide to take a higher risk and divide our bets to the number of games in each week accordingly. Achieving an active rollover of our whole bankroll every week.
total_hdp_bankroll_week <- total_hdp_return %>%
mutate( wongames = ifelse(win == "W",1,0)) %>%
group_by(week = floor_date(Date,"week")) %>%
summarise(earnings = sum(earnings),
games = n(),
gameswon = sum(wongames),
ROI = round((earnings/games)*100,2),
M.factor = ((ROI+100)/100)) %>%
filter(games > 2) %>%
mutate(winpct = round(gameswon*100/games,2),
bankroll = cumsum(earnings),
T.ROI = cumprod(M.factor)) %>%
mutate(T.ROI = T.ROI*100)
total_hdp_bankroll_week ggplot(total_hdp_bankroll_week)+
geom_line(aes(x = week, y = bankroll))+
geom_point(aes(x = week, y = bankroll))+
labs(y = "Progression of Bankroll in (Units)") ggplot(total_hdp_bankroll_week)+
geom_line(aes(x = week, y = T.ROI))+
geom_point(aes(x = week, y = T.ROI))+
labs(y = "Progression of Bankroll in (%)")We conclude that a higher winrate will not guarantee you a profit from the betting market. Filtering and finding value in the odds/payout is the essential part in this business.
As you can see, applying our optimum odds value parameters yields greater profits in the second quarter of the season.From the Initial 3.635 units to 22.595 units.
ggplot(total_hdp_bankroll)+
geom_line(aes(x = Date, y = bankroll))+
geom_point(aes(x = Date, y = bankroll))+
geom_line(data = hdp_bankroll,aes(x = Date, y = bankroll, colour = "red"))+
geom_point(data = hdp_bankroll,aes(x = Date, y = bankroll, colour = "red"))+
labs(y = "Bankroll Progress (Units)")