Skip to main content

CLI & library to compute sports bet hedging scenarios — guaranteed profit regardless of outcome.

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bet_hedge_calculator-0.1.0.tar.gz (11.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bet_hedge_calculator-0.1.0-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file bet_hedge_calculator-0.1.0.tar.gz.

File metadata

  • Download URL: bet_hedge_calculator-0.1.0.tar.gz
  • Upload date:
  • Size: 11.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.10

File hashes

Hashes for bet_hedge_calculator-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6e0bd9d0d8d3ceae5c1574e85920ded68bb4d7685c4288a017e5a1fa59143320
MD5 baae41f9d553e4de8123d317313bf445
BLAKE2b-256 758d53f1661c5918b9e6a92c84b346bc9bfbc1159b1c4df68bd5e3ec4e84f96e

See more details on using hashes here.

File details

Details for the file bet_hedge_calculator-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for bet_hedge_calculator-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ce2d0cf35b395746d237f0aeb29cc33982313193ec6ddfbcd17d6f7007dc9ec2
MD5 d00c2e648d8ca50021d5108b38265110
BLAKE2b-256 d3287064018bf1c19419938c4779f1bf5186a05054398f541856583777e8bffc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page