Skip to content

Fix KellyBet formula: use payout-1 for net odds - #14

Merged
jonnyspicer merged 1 commit into
mainfrom
fix/issue-9-kelly-formula
Feb 16, 2026
Merged

jonnyspicer merged 1 commit into
mainfrom
fix/issue-9-kelly-formula

Conversation

@jonnyspicer

Copy link
Copy Markdown
Owner

Summary

  • Fixes the Kelly Criterion formula in KellyBet() to use payout - 1 instead of payout / 2 for calculating net odds from decimal odds
  • Adds a guard clause returning 0.0 when payout <= 1 (prevents division by zero and negative net odds)
  • Replaces single test case with table-driven tests covering 6 scenarios including edge cases

Test plan

  • All existing tests continue to pass
  • New test cases verify correct formula output for various prob/payout combinations
  • Edge cases for payout <= 1 return 0.0
  • go vet passes cleanly

Fixes #9

🤖 Generated with Claude Code

The formula was dividing payout by 2 instead of subtracting 1.
Since payout represents decimal odds, net odds = payout - 1.

Also adds a guard for payout <= 1 (division by zero / negative net odds)
and expands tests with table-driven cases covering edge cases.

Fixes #9

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jonnyspicer
jonnyspicer merged commit 246ce1e into main Feb 16, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

KellyBet formula uses payout/2, producing incorrect results

1 participant