go-odds is a simple and fast utility library for making betting odds conversions between formats and calculating probabilities in Go.
Go gopher illustration created by Egon Elbre, originally created by Renee French.
- Installation
- Converting odds between formats
- Overround and Payouts
- Arbitrage Calculation
- Kelly Criterion
- Simple Parlay Bets
Download the library using go get:
go get github.com/jsgm/go-odds
Import in your current repository:
import (
odds "github.com/jsgm/go-odds"
)
Each odd type will return a different data type, depending on your needs.
Odd format | Function | Type |
---|---|---|
Moneyline | .Moneyline() | int16 |
Indonesian | .Indonesian() | float64 |
Malay | .Malay() | float64 |
Decimal | .Decimal() | float64 |
HongKong | .HongKong() | float64 |
Implied Probability | .Probability() | float64 |
o := odds.NewOdd(odds.Decimal, 1.64)
// Convert to implied probability
float := o.Probability()
home, _ := odds.NewOdd(odds.Implied, 65.00) // Home odds from Implied Probability
draw, _ := odds.NewOdd(odds.Decimal, 4.00)
away, _ := odds.NewOdd(odds.Decimal, 7.00)
fmt.Println("Overround ", odds.GetOverround([]odds.Odd{home, draw, away})) // 4.285714285714278
fmt.Println("Payout ", odds.GetPayout([]odds.Odd{home, draw, away})) // 95.71428571428572
todo
Kelly Criterion is simply strategy that helps calculating the proper stake that you should wager on a particular event. This doesn't just applies to betting but also for investing and calculating risks.
- b is the multiple of the stake.
- p is the probability of winning. 70% chances of winning should be 0.7.
- q is the probability of lossing. i.e. 100% - p = 30. The value would be 0.3.
- K% is the suggested percentage of the bankroll for the event.
o1, _ := odds.NewOdd(odds.Decimal, 1.25)
o2, _ := odds.NewOdd(odds.Implied, 50.7)
o3, _ := odds.NewOdd(odds.Decimal, 4.5)
multi := []odds.Odd{o1, o2, o3}
stake := 10.0
p := odds.NewParlay(multi, stake)
p.Profit() // 67.22386587771203
p.Payout() // 77.22386587771203
p.SellectionCount() // 3
p.Probability() // 12.949364663814572 (%)
todo
todo