定制 jsgm/odds-php 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

jsgm/odds-php

Composer 安装命令:

composer require jsgm/odds-php

包简介

README 文档

README

Building License

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:

composer require jsgm/odds-php

Alternatively, you can clone the repository directly:

git clone https://github.com/jsgm/odds-php.git

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.

// Converting decimal to fractional.
$odd = new  Odds();
echo  $odd->set('decimal', 5.50)->get('fractional'); // "string" 9/2

// Converting fractionalto moneyline.
$odd = new  Odds();
echo  $odd->set('fractional', '11/25')->get('moneyline'); // "float" -227

// Converting fractional to implied probability.
$odd = new  Odds();
echo  $odd->set('fractional', '44/100')->get('implied'); // "string" 69.44

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:

print $odd->set('fractional', '44/100')->reduce(); // "string" 11/25
print $odd->set('fractional', '44/100')->get('fractional'); // "string" 11/25

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:

$odd = new Odds();
$odd->set_precision(1);
$odd->set('decimal', 1.29)->get('decimal'); // "float" 1.3


$odd->set_precision(2);
$odd->set('decimal', '1,800.00')->get('decimal'); // "float" 1800.00

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

$group = [['decimal', 4.45], ['decimal', 3.40], ['decimal', 1.90]];

// Use the 'Payouts' class and don't forget to require it at the beginning of your code.
$payout = new Payouts($group);

The payout is calculated by simply subtracting the overround to 100. This can be done using the following method:

print  $payout->get_payout(); // "float" 95.49

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.

// 100 / (decimal odd) = implied probability
var_dump($payout->get_implied_probabilities()); // [22.47, 29.41, 52.63]

If we sum all of them we will have a remaining percentage, that's the overround.

// array_sum([22.47, 29.41, 52.63]) = 104.51
// 104.51 - 100 = Overround
print  array_sum($payout->get_implied_probabilities()); // "float" 104.51
print  $payout->get_overround(); // "float" 4.51

We can also get the real probabilities for a group of odds:

// Formula: 100 / [Odd * (Payout / 100)] = real probability
$payout->get_real_probabilities(); // [23.53, 30.8, 55.12]

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.

Surebet example

// The 'Payouts' class has to be required in order to use 'Surebets'.
$surebet = new Surebets([['decimal', 2.3], ['decimal', 3.3], ['decimal', 3.97]]);
if($surebet->is_surebet()){
	print 'Surebet found! :)';
	// '.($surebet->profit()).'% profit!';
}else{
	print 'Sorry! :( No surebet found!';
}

jsgm/odds-php 适用场景与选型建议

jsgm/odds-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2 次下载、GitHub Stars 达 6, 最近一次更新时间为 2026 年 04 月 10 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 jsgm/odds-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 jsgm/odds-php 我们能提供哪些服务?
定制开发 / 二次开发

基于 jsgm/odds-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 2
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 10
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 6
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-10