feat: hedgeBet() — lock in guaranteed profit on line-movement scenarios#26
Merged
Conversation
Adds hedgeBet(originalStake, originalAmericanOdds, hedgeAmericanOdds) which computes the stake on the opposite side that equalises gross returns in both outcomes. Classic use: early underdog bet that has moved in your favour — calculate exactly how much to hedge for a risk-free profit. Returns hedgeStake, guaranteedProfit, isProfit, roi, totalRisked, grossReturn. Five new tests cover the profitable-hedge, break-even, loss, gross-parity, and input-validation cases. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
hedgeBet(originalStake, originalAmericanOdds, hedgeAmericanOdds)to the kelly-js APIhedgeStake,guaranteedProfit,isProfit,roi,totalRisked, andgrossReturnClassic use case: you placed an early-season bet at +300 and the underdog has made the final. The opposite side is now available at +100.
hedgeBet(100, 300, 100)tells you to stake $200 on the other side, locking in $100 profit regardless of who wins.The formula is
hedgeStake = originalStake × decimal(originalOdds) / decimal(hedgeOdds), which equalises the gross payout for both outcomes.isProfitis true when that gross return exceeds the combined stakes.Test plan
hedgeStake × dHedge === originalStake × dOrig)RangeError)npm run lintclean (TypeScript 7 + type check)🤖 Generated with Claude Code