Skip to main content

bet-hedge-calculator

A CLI tool and Python library for computing sports bet hedging scenarios.

Given a bet already placed on Team A, it shows you exactly what odds and stake you need on Team B to guarantee a fixed profit — regardless of which team wins.


Installation

pip install bet-hedge-calculator

CLI Usage

After installation a bet-hedge-calc command is available globally.

Interactive mode (prompts for input):

bet-hedge-calc

Direct mode (pass values as flags):

bet-hedge-calc --odds-a 2.50 --stake-a 100

Custom ROI range and step:

bet-hedge-calc --odds-a 3.0 --stake-a 200 --roi-min -10 --roi-max 100 --roi-step 2.5

All options:

--odds-a    Decimal odds of Team A (e.g. 2.50)
--stake-a   Your stake on Team A (e.g. 100)
--roi-min   Minimum target ROI % (default: -20)
--roi-max   Maximum target ROI % (default: 200)
--roi-step  ROI step size in % (default: 5)
--currency  Currency symbol (default: £)

Example output

═══ Bet Hedging Calculator ═══

╭─────────────────────────────────────────────────────────────────────────────────────╮
│         Hedging Calculator  —  Team A odds: 2.5  |  Stake on A: £100.00            │
├───────────────┬─────────────────┬───────────────┬─────────────────┬───────────────┤
│    Target ROI │ Required Odds B │  Stake on B   │ Total Invested  │  Guaranteed   │
│               │                 │     (£)       │      (£)        │   Profit (£)  │
├───────────────┼─────────────────┼───────────────┼─────────────────┼───────────────┤
│        -20.0% │         1.1765  │      £212.50  │       £312.50   │      -£62.50  │
│        -15.0% │         1.2195  │      £205.00  │       £305.00   │      -£45.75  │
│        -10.0% │         1.2658  │      £197.50  │       £297.50   │      -£29.75  │
│         -5.0% │         1.3158  │      £190.00  │       £290.00   │      -£14.50  │
│          0.0% │         1.6667  │      £150.00  │       £250.00   │        £0.00  │
│         +5.0% │         1.7500  │      £142.86  │       £242.86   │       £12.14  │
│        +10.0% │         1.8333  │      £136.36  │       £236.36   │       £23.64  │
│        +20.0% │         2.0000  │      £125.00  │       £225.00   │       £45.00  │
│        +50.0% │         2.5000  │      £100.00  │       £200.00   │      £100.00  │
│       +100.0% │              —  │            —  │             —   │            —  │
│               │                 Not achievable                                     │
╰─────────────────────────────────────────────────────────────────────────────────────╯

Python API

Import the library directly to get raw data or render the table programmatically.

Get hedging data

from bet_hedge_calculator import calculate_scenarios

scenarios = calculate_scenarios(odds_a=2.5, stake_a=100)

for s in scenarios:
    if s.valid:
        print(f"ROI {s.roi_pct:+.1f}%  →  odds B: {s.odds_b:.4f}  |  stake B: £{s.stake_b:.2f}  |  profit: £{s.guaranteed_profit:.2f}")

Output:

ROI -20.0%  →  odds B: 1.1765  |  stake B: £212.50  |  profit: £-62.50
ROI -15.0%  →  odds B: 1.2195  |  stake B: £205.00  |  profit: £-45.75
...
ROI +10.0%  →  odds B: 1.8333  |  stake B: £136.36  |  profit: £23.64

Render the rich table

from bet_hedge_calculator import calculate_scenarios, render_table

scenarios = calculate_scenarios(odds_a=2.5, stake_a=100)
render_table(scenarios, odds_a=2.5, stake_a=100, currency="$")

Single scenario

from bet_hedge_calculator import calculate_scenario

s = calculate_scenario(odds_a=3.0, stake_a=200, roi=0.10)  # 10% ROI
if s.valid:
    print(f"Stake £{s.stake_b:.2f} on Team B at odds {s.odds_b:.4f}")
    print(f"Guaranteed profit: £{s.guaranteed_profit:.2f}")

Custom ROI range

from bet_hedge_calculator import calculate_scenarios

scenarios = calculate_scenarios(
    odds_a=2.5,
    stake_a=100,
    roi_min_pct=0.0,
    roi_max_pct=50.0,
    roi_step_pct=2.5,
)

HedgeScenario dataclass

Each scenario is a HedgeScenario with these fields:

Field Type Description
roi_pct float Target ROI in percent (e.g. 10.0)
valid bool False when the scenario is mathematically unachievable
odds_b float | None Required decimal odds for Team B
stake_b float | None Required stake on Team B
total_invested float | None Combined stake on A + B
guaranteed_profit float | None Profit regardless of outcome

The maths

For a bet already placed on Team A (decimal odds O_A, stake S_A), we want a guaranteed profit P regardless of which team wins:

If A wins:  S_A × O_A − S_A − S_B = P
If B wins:  S_B × O_B − S_B − S_A = P

Both equations give S_A × O_A = S_B × O_B, so:

O_B = O_A × (1 + ROI) / (O_A − 1 − ROI)
S_B = S_A × O_A / O_B

This is valid only when ROI < O_A − 1. Rows outside this range are marked Not achievable.


Development

git clone https://github.com/your-username/bet-hedge-calculator
cd bet-hedge-calculator
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
pytest tests/ -v

License

MIT

Release files for bet-hedge-calculator 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bet-hedge-calculator 0.1.1
File Size Uploaded
bet_hedge_calculator-0.1.1.tar.gz 11.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bet-hedge-calculator 0.1.1
File Interpreter ABI Platform
bet_hedge_calculator-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 19.6 kB

Release files / bet_hedge_calculator-0.1.1.tar.gz

Download URL bet_hedge_calculator-0.1.1.tar.gz
Size 11.4 kB
Tags Source
SHA-256 checksum
How to use checksums
26386886c34abddbc762e76e6b3d0aa0dd2c9a42832adf61566e497b25519742
BLAKE2b-256 checksum
How to use checksums
d9a7d8b59d22d3f98ca72fe3f7d6a771fa219ffb54a4a588e7bfd07ed55be8d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.10

Release files / bet_hedge_calculator-0.1.1-py3-none-any.whl

Download URL bet_hedge_calculator-0.1.1-py3-none-any.whl
Size 8.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
893417c0338417dec191af587c59cbe0e8c4e291aba7e3631ebd3ae408499d20
BLAKE2b-256 checksum
How to use checksums
a5f91640161fc67c17f0c65f2f939332f536fbb7d11df622d0a5037b1245b596
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.10

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page