agentleFS
ianallowayianalloway/openclaw-skills/kelly-criterion/SKILL.md

kelly-criterion

Skill4 starsChanged 5 months agoMITView on GitHub

Calculate optimal bet sizes using the Kelly Criterion formula. Maximize long-term bankroll growth while managing risk.

3 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

2 rules. 0 are common, 2 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 3 edited versions we read keep these.

  • 2

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    If Kelly returns negative, you have no edge - don't bet

    line 182
  2. Distinctive:

    If Kelly > 25%, double-check your probability estimate

    line 183

“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Kelly Criterion Calculator

Calculate mathematically optimal bet sizes to maximize long-term bankroll growth while managing risk. The Kelly Criterion is used by professional bettors and investors to determine position sizing.

The Formula

Kelly % = (bp - q) / b

Where:

  • b = decimal odds - 1 (net odds received on the bet)
  • p = probability of winning
  • q = probability of losing (1 - p)

Quick Calculator

Basic Kelly calculation (Python one-liner)

# Usage: kelly(win_probability, decimal_odds)
python3 -c "
def kelly(p, odds):
    b = odds - 1
    q = 1 - p
    k = (b * p - q) / b
    return max(0, k)

# Example: 55% win probability at 2.0 odds (even money)
prob, odds = 0.55, 2.0
print(f'Kelly: {kelly(prob, odds):.2%} of bankroll')
"

Convert American odds to decimal

python3 -c "
def american_to_decimal(american):
    if american > 0:
        return (american / 100) + 1
    else:
        return (100 / abs(american)) + 1

# Example: -110 American odds
american = -110
decimal = american_to_decimal(american)
print(f'{american:+d} American = {decimal:.3f} decimal')
"

Full Kelly Calculator with fractional Kelly

python3 -c "
def kelly_full(win_prob, decimal_odds, fraction=1.0, bankroll=1000):
    b = decimal_odds - 1
    q = 1 - win_prob
    kelly_pct = max(0, (b * win_prob - q) / b)
    fractional = kelly_pct * fraction
    bet_amount = bankroll * fractional
    
    print(f'Win Probability: {win_prob:.1%}')
    print(f'Decimal Odds: {decimal_odds:.2f}')
    print(f'Full Kelly: {kelly_pct:.2%}')
    print(f'{fraction:.0%} Kelly: {fractional:.2%}')
    print(f'Bet Amount: \${bet_amount:.2f} (on \${bankroll} bankroll)')
    
    # Expected value
    ev = (win_prob * (decimal_odds - 1)) - (1 - win_prob)
    print(f'Expected Value: {ev:.2%} per unit')

# Example: 60% edge at -150 odds, using half Kelly on $1000 bankroll
kelly_full(0.60, 1.667, fraction=0.5, bankroll=1000)
"

Common Scenarios

Sports Betting: Find edge and optimal bet

python3 -c "
def analyze_bet(your_prob, market_odds_american, bankroll=1000):
    # Convert American to decimal
    if market_odds_american > 0:
        decimal_odds = (market_odds_american / 100) + 1
    else:
        decimal_odds = (100 / abs(market_odds_american)) + 1
    
    # Implied probability from market
    implied_prob = 1 / decimal_odds
    
    # Your edge
    edge = your_prob - implied_prob
    
    # Kelly calculation
    b = decimal_odds - 1
    kelly_pct = max(0, (b * your_prob - (1 - your_prob)) / b)
    
    print(f'Your probability: {your_prob:.1%}')
    print(f'Market odds: {market_odds_american:+d} ({decimal_odds:.3f} decimal)')
    print(f'Implied probability: {implied_prob:.1%}')
    print(f'Your edge: {edge:+.1%}')
    print(f'Full Kelly: {kelly_pct:.2%}')
    print(f'Half Kelly bet: \${bankroll * kelly_pct * 0.5:.2f}')
    
    if edge <= 0:
        print('WARNING: No edge - do not bet!')

# Example: You think team has 58% chance, market has them at -130
analyze_bet(0.58, -130, bankroll=1000)
"

Multi-bet Kelly (simultaneous independent bets)

python3 -c "
def multi_kelly(bets, bankroll=1000):
    '''
    bets: list of (name, win_prob, decimal_odds) tuples
    '''
    total_kelly = 0
    print(f'Bankroll: \${bankroll}')
    print('-' * 50)
    
    for name, prob, odds in bets:
        b = odds - 1
        kelly = max(0, (b * prob - (1 - prob)) / b)
        total_kelly += kelly
        bet_amt = bankroll * kelly * 0.5  # Half Kelly
        print(f'{name}: {kelly:.2%} Kelly -> \${bet_amt:.2f} (half)')
    
    print('-' * 50)
    print(f'Total exposure: {total_kelly:.2%} (full) / {total_kelly*0.5:.2%} (half)')
    
    if total_kelly > 1:
        print('WARNING: Over-leveraged! Reduce bet sizes.')

# Example: Three simultaneous bets
bets = [
    ('Lakers ML', 0.55, 2.10),
    ('Chiefs -3', 0.52, 1.91),
    ('Yankees ML', 0.48, 2.20),  # No edge - will show 0
]
multi_kelly(bets, bankroll=1000)
"

Fractional Kelly Recommendations

Risk ToleranceKelly FractionUse Case
Aggressive100% (Full)Maximum growth, high variance
Moderate50% (Half)Good balance, recommended for most
Conservative25% (Quarter)Lower variance, slower growth
Very Conservative10%Minimal drawdowns

Tips

  1. Never bet more than Kelly suggests - overbetting leads to ruin
  2. Use fractional Kelly (25-50%) - reduces variance significantly
  3. Be honest about your edge - overestimating probability is the #1 mistake
  4. Track your results - adjust probabilities based on actual performance
  5. Account for correlation - reduce sizes when bets are correlated

Edge Cases

  • If Kelly returns negative, you have no edge - don't bet
  • If Kelly > 25%, double-check your probability estimate
  • For parlays, calculate the combined probability and use parlay odds

Author

Created by Ian Alloway - Data Scientist specializing in sports analytics and ML.

License

MIT License

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.