Betting Odds Conversion

Conversion between the most common odds types for sports betting. Hong Kong odds, US odds, Decimal odds, Indonesian odds, Malaysian odds, and raw Probability are covered in this package.


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")

News

odds.converter v1.4.8 (Release date: 2018-05-28)

Changes:

  • Refactored odds.fv and added odds.vig to calculate the overround directly. Thanks to bkmontgom for the pull request!

odds.converter v1.4.7 (Release date: 2018-05-01)

Changes:

  • Replaced ifelse to speed up the code execution. Thanks to bkmontgom for the pull request!

odds.converter v1.4.6 (Release date: 2017-6-23)

Changes:

  • Reintroduced Vectorized2wayOutput1stElement to odds.fv()

odds.converter v1.4.5 (Release date: 2017-6-23)

Changes:

  • Updated documentation
  • reverted the changed introduced in 1.4

odds.converter v1.4 (Release date: 2017-1-11)

Changes:

  • Added Vectorized2wayOutput1stElement to odds.fv to speed up the calculation in dplyr chains

odds.converter v1.4 (Release date: 2016-3-1)

Changes:

  • Added odds.parlay to convert odds into parlay odds

odds.converter v1.3 (Release date: 2015-10-17)

Changes:

  • Added functionality to odds.fv(). It can now handle data.frames as input and vectors

odds.converter v1.2 (Release date: 2015-09-25)

Changes:

  • Added odds.dec2all and similar functions to allow the conversion into all odds formats

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("odds.converter")

1.4.8 by Marco Blume, a year ago


Browse source code at https://github.com/cran/odds.converter


Authors: Marco Blume , Sascha Thomsen


Documentation:   PDF Manual  


GPL-3 license


Suggests testthat


Suggested by pinnacle.data.


See at CRAN