Learn R Programming

odds.converter

This package includes functions to transform sports betting odds from one format into another.

These betting odds formats are covered in odds.converter at the moment

  • US Odds (shortform us)
  • Decimal Odds (shortform dec)
  • Probability (shortform prob)
  • Honk Kong Odds (shortform hk)
  • Malaysian Odds (shortform malay)
  • Indonesian Odds (shortform indo)

Please contact me if there is a betting odds format that needs to be added to this package.

Fractional Odds commonly used by bookmakers in the U.K. are not included as the transformation of these Odds is not very well defined and Fractional Odds are not used outside of the U.K and have been largely replaced by Decimal Odds.

Installation

# Install from Cran
install.packages("odds.converter")

# Or the the development version from GitHub:
# install.packages("devtools")
devtools::install_github("marcoblume/odds.converter")

Usage

Transform specific odds into specific odds

The package contains functions to transform one specific odds type into another specific odds type. These functions are called:

odds.Shortform2Shortform

For example

library(odds.converter)
odds.us2dec(-115)
odds.prob2malay(0.5)
odds.indo2hk(0.8)

Transform specific odds into all other odds format

To transform a specific odds type into all other odds type use the functions that are called odds.Shortform2all

For example

library(odds.converter)
odds.dec2all(-115)
odds.prob2all(0.5)
odds.indo2all(0.8)

Calculating the implied probability (fair value) of betting odds

Bookmakers will include a margin to their betting odds that will increase the total probability of the offered odds above 100%. If a bookmaker would offer a coin flip instead of offering 50% for heads and 50% for tails the bookmaker would have 51% for heads and 51% for tails for example thus guaranteeing that they would make a small profit for every wager on the coin flip.

odds.prob2dec(0.51)

To calculate the margin that bookmaker offers convert the odds into probability and sum them.

Betting Odds:

Manchester United Decimal Odds 1.3 Arsenal Decimal Odds 9.0 Draw Decimal Odds 4.0

sum(odds.dec2prob(c(1.3,9,4)))
1.130342

The build margin is slightly over 13%

To calculate the real implied probability use the function odds.fv()

Example: Calculate the implied probability of the above match without margin added

odds.fv(1.3,9,4,input = "dec",output = "dec")
1.469444 10.173077  4.521368

Example: Calculate the implied probability of the above match without margin added

odds.fv(1.3,9,4,input = "dec",output = "prob")
0.68052930 0.09829868 0.22117202

Example: Calculate the implied probability of a data.frame containing Home and Away odds

df <- data.frame(Home = c(1.5,1.8,1.9),
                 Away = c(2.9,2.2,2.05))
odds.fv(df,input = "dec",output = "prob")
        Home      Away
[1,] 0.6590909 0.3409091
[2,] 0.5500000 0.4500000
[3,] 0.5189873 0.4810127

It is also possible to submit vectors as input to calculate the implied Probability

odds.fv(df$Home,df$Away,input="dec",output="prob")

Example: Calculate the implied probablity of home and away lines with dplyr

library(dplyr)

df <- data.frame(Home = c(1.5,1.8,1.9),
                 Away = c(2.9,2.2,2.05))
                 

df %>% 
  rowwise() %>% 
  mutate(FairHome = odds.fv(Home,Away,
                            input =   "dec",
                            output = "prob")[1]) %>% 
  mutate(FairAway = 1 - FairHome)

As rowwise() slows down the calculation and the calculation of fair values for Home and Away odds is a common use case odds.fv() has an option (Vectorized2wayOutput1stElement = TRUE), which can speed up the computation significantly for this specific use case.

df %>% 
  mutate(FairHome = odds.fv(Home,Away,
                            input =   "dec",
                            output = "prob",
                            Vectorized2wayOutput1stElement = TRUE)) %>% 
  mutate(FairAway = 1 - FairHome)

Calculate Parlays

To calculate the fair price for a parlay input the betting odds of each of the parlay legs and use odds.parlay()

odds.parlay(c(-105,-110),output="dec")

Copy Link

Version

Install

install.packages('odds.converter')

Monthly Downloads

280

Version

1.4.8

License

GPL-3

Maintainer

Last Published

June 1st, 2018

Functions in odds.converter (1.4.8)

odds.malay2indo

Convert Malaysian odds to Indonesian odds
odds.prob2dec

Convert Probabilities to Decimal odds
odds.indo2all

Convert Indonesian to all other formats
odds.hk2us

Convert Hong Kong Odds to US Odds
odds.malay2us

Convert Malaysian odds to US odds
odds.parlay

Transfer a vector to odds into correct parlay odds
odds.prob2indo

Convert Probabilities to Indonesian odds
odds.prob2hk

Convert Probabilities to Hong Kong odds
odds.prob2us

Convert Probabilities to US odds
odds.us2indo

Convert US odds to Indonesian odds
odds.us2all

Convert US Odds to all other formats
odds.us2dec

Convert US odds to Decimal odds
odds.prob2malay

Convert Probabilities to Malaysian odds
odds.malay2prob

Convert Malaysian odds to Probabilities
odds.us2hk

Convert US odds to Hong Kong odds
odds.malay2hk

Convert Malaysian odds to Hong Kong odds
odds.malay2dec

Convert Malaysian odds to Decimal odds
odds.us2malay

Convert US odds to Malaysian odds
odds.us2prob

Convert US odds to Probabilities
odds.dec2all

Convert Decimal Odds to all other formats
odds.dec2us

Convert Decimal Odds to US Odds
odds.fv

Calculate the fair (vigorish free) odds for a vector of vigged odds.
odds.dec2indo

Convert Decimal Odds to Indonesian odds
odds.dec2hk

Convert Decimal Odds to Hong Kong odds
odds.dec2malay

Convert Decimal Odds to Malaysian odds
odds.hk2dec

Convert Hong Kong Odds to Decimal Odds
odds.hk2all

Convert Hong Kong Odds to all other formats
odds.indo2dec

Convert Indonesian odds to Decimal odds
odds.hk2malay

Convert Hong Kong Odds to Malaysian Odds
odds.indo2prob

Convert Indonesian odds to Probabilities
odds.indo2us

Convert Indonesian odds to US odds
odds.malay2all

Convert Malaysian Odds to all other formats
odds.indo2malay

Convert Indonesian odds to Malaysian odds
odds.dec2prob

Convert Decimal Odds to Probabilities
odds.indo2hk

Convert Indonesian odds to Hong Kong odds
odds.hk2indo

Convert Hong Kong Odds to Indonesian Odds
odds.hk2prob

Convert Hong Kong Odds to Probabilities
odds.prob2all

Convert Probabilities to to all other formats