Download the PHP package jsgm/odds-php without Composer
On this page you can find all versions of the php package jsgm/odds-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package odds-php
OddsPHP
OddsPHP is a lightweight library to easily work with odds conversions and calculations.
With a few lines of code you'll be able to:
- Odds conversions between decimal, fractional, american and implied probability.
- Calculate payouts and overrounds.
- Getting the real probabilities.
- Surebets calculations.
Installation
The recommended way to install odds-php is via Composer:
Alternatively, you can clone the repository directly:
1. Working with odds
1.1 Convert odds between formats
Convert odds between different types of formats. If the given odd is not valid it will throw an exception.
Allowed formats are:
- 'decimal'
- 'fractional'
- 'implied'
- 'moneyline'
- 'hongkong'
- 'malay'
- 'indonesian'
1.2 Reduce to the lowest term a fractional odd
Reduce a fraction with the reduce() method or just pass any fraction and it will automatically reduce it for you as shown here:
Bookmarkers always use the simplest form of a fraction and you should do too.
1.3 Set decimal and percentage precision
By default, all decimal odds and percentages will be returned with 2 decimals. You can modify that by using:
2. Calculating payouts and overrounds
Now that you know how to convert odds in a few seconds, OddsPHP also includes a few tools to help you doing extra calculations easily.
The payouts are the amount of money given back to the user who won a bet whereas the overround is the profit that the bookie takes. If you don't know this concepts, check this website where you can find a bunch of examples.
| Let's assume we have the following market with the given odds: | Home Team | Draw | Away Team |
|---|---|---|---|
| 4.45 | 3.40 | 1.90 |
This group of odds will be defined in our code like this (Rembember that you also can mix different odd formats):
The payout is calculated by simply subtracting the overround to 100. This can be done using the following method:
Getting the implied probabilities for each odd. This probabilities are not real since the bookmarker comission is added. You may need them if you want to calculate by yourself.
If we sum all of them we will have a remaining percentage, that's the overround.
We can also get the real probabilities for a group of odds:
We may get at some point a negative result for the overround. That means we have found a surebet!
3. Surebets
We can check for a surebet given a odds set. Remember that you will need at least 2 different odds bookmarkers. The next example is a real surebet case. As you might have noticed the odds are provided by different bookies.
