Keeks 0.3.0: Introducing the Merton Share Strategy

Keeks 0.3.0: Introducing the Merton Share Strategy

I’m excited to announce Keeks 0.3.0, which introduces a powerful new betting strategy based on Robert Merton’s portfolio optimization work. This release also adds the ability to calculate maximum entry prices for one-time gambles, complete with examples that explore the famous St. Petersburg paradox.

What’s New

The highlight of this release is the MertonShare strategy, which gives you explicit control over risk aversion in a way that the Kelly Criterion doesn’t. Here’s what’s included:

  • MertonShare Strategy - Based on Merton’s 1969 portfolio problem with Constant Relative Risk Aversion (CRRA) utility
  • Configurable Risk Aversion - Adjust the risk aversion parameter (γ) from 1.0 (Kelly-like) to 5.0+ (very conservative)
  • Entry Price Methods - All 9 strategies now calculate maximum entry prices for one-time gambles
  • St. Petersburg Paradox Example - See how different strategies value infinite expected value gambles
  • Strategy Comparison Example - Compare performance across 1000 repeated bets
  • 123 Tests with 95% Coverage - Comprehensive testing and validation

The Merton Share: Kelly with a Risk Knob

The Kelly Criterion is fantastic for maximizing long-term growth, but it assumes you want to maximize the logarithm of wealth. What if you’re more (or less) risk-averse than that?

Enter the Merton Share. In 1969, Robert Merton published his groundbreaking work on portfolio optimization that lets you specify your risk preferences through a single parameter: γ (gamma), the coefficient of relative risk aversion.

The formula is elegantly simple:

f* = μ / (γ × σ²)

Where:

  • f* is the optimal fraction to bet
  • μ is expected excess return
  • γ is your risk aversion (1 = Kelly, higher = more conservative)
  • σ² is variance of returns

The beauty here is flexibility:

  • γ = 1.0: Matches Kelly (aggressive, log utility)
  • γ = 2.0: Moderate risk aversion (empirically typical)
  • γ = 3-5: Conservative
  • γ > 5: Very conservative

This is crucial when you’re uncertain about probabilities, managing institutional capital, or just prefer more predictable outcomes than full Kelly provides.

Using MertonShare

Getting started is straightforward:

from keeks.bankroll import BankRoll
from keeks.binary_strategies.simple import MertonShare
from keeks.simulators.repeated_binary import RepeatedBinarySimulator

# Create a bankroll
bankroll = BankRoll(initial_funds=1000.0, max_draw_down=0.3)

# Create a Merton Share strategy with moderate risk aversion
strategy = MertonShare(
    payoff=1.0,
    loss=1.0,
    transaction_cost=0.01,
    risk_aversion=2.0,  # γ = 2.0 (moderate)
    min_probability=0.5,
    max_fraction=1.0
)

# Run a simulation with 55% win rate
simulator = RepeatedBinarySimulator(
    payoff=1.0,
    loss=1.0,
    transaction_costs=0.01,
    probability=0.55,
    trials=1000
)

simulator.evaluate_strategy(strategy, bankroll)
bankroll.plot_history()

Entry Price Calculation: A New Feature

One of the biggest additions in v0.3.0 is the ability to calculate maximum entry prices for one-time gambles. This is fundamentally different from repeated betting: you’re asking “What’s the most I should pay to participate in this single gamble?”

All 9 strategies now implement calculate_max_entry_price() using their own decision-making framework. For the Merton Share, this uses CRRA utility to find the indifference price where you’re equally happy paying to play or keeping your wealth.

from keeks.binary_strategies.simple import MertonShare

strategy = MertonShare(
    payoff=1.0,
    loss=1.0,
    transaction_cost=0.0,
    risk_aversion=2.0
)

# St. Petersburg outcomes (first 30 flips)
outcomes = [2**n for n in range(1, 31)]
probabilities = [(0.5)**n for n in range(1, 31)]

max_price = strategy.calculate_max_entry_price(
    outcomes=outcomes,
    probabilities=probabilities,
    current_wealth=10000.0
)

print(f"Maximum price to pay: ${max_price:.2f}")

The St. Petersburg Paradox

The St. Petersburg paradox is a famous probability puzzle that has stumped people for centuries:

  • Flip a fair coin repeatedly until tails appears
  • Payout is $2^n where n is the number of flips
  • Expected value is infinite: E[X] = Σ(1/2^n × 2^n) = ∞

The paradox: despite infinite expected value, no rational person would pay much to play. The new example in Keeks shows exactly how much each strategy would pay.

Results at Different Wealth Levels

Strategy$1$10$100$1,000
Kelly$0.50$4.97$7.79$10.95
Merton (γ=2.0)$0.50$3.96$6.49$9.55
Merton (γ=5.0)$0.50$3.10$5.20$8.06
Naive$1.00$10.00$100.00$1,000.00

The naive “expected value maximizer” would pay 100% of wealth regardless of bankroll size, which would obviously bankrupt you. Utility-based strategies like Kelly and Merton pay finite, rational amounts that scale logarithmically with wealth.

This resolves the paradox: rational agents with diminishing marginal utility of wealth pay modest amounts for infinite expected value because each additional dollar matters less than the previous one.

Strategy Comparison Over 1000 Bets

The release includes a comprehensive comparison showing how strategies perform with repeated betting (55% win rate, 1:1 payoff, 1000 trials, 1000 simulations):

StrategyMeanStd DevRuin Rate
Kelly Criterion$1,316.52$397.430.0%
Merton (γ=1.0)$1,301.11$379.230.0%
Merton (γ=2.0)$1,102.08$154.930.0%
Merton (γ=5.0)$1,012.83$60.750.0%

Key insights:

  1. Merton (γ=1.0) ≈ Kelly: As expected, they’re nearly identical ($1,301 vs $1,316)
  2. Lower Volatility: Merton (γ=2.0) achieved 61% lower standard deviation while retaining 84% of returns
  3. Risk-Return Trade-off: Merton (γ=5.0) sacrificed returns for stability with only $60.75 std dev vs Kelly’s $397.43

When to Use Merton vs. Kelly

Use Kelly When:

  • You have accurate probability estimates
  • You’re optimizing for long-term growth
  • You can tolerate significant volatility
  • You’re betting with recreational capital

Use Merton When:

  • You have uncertainty about probabilities
  • You want to control downside risk
  • You have specific risk tolerance requirements
  • You’re managing others’ money or institutional capital
  • You want more consistent, predictable outcomes

Installation

Upgrade to the latest version:

pip install --upgrade keeks

Explore the Examples

The release includes two comprehensive examples:

# Strategy comparison (repeated betting)
python examples/strategy_comparison.py

# St. Petersburg paradox (one-time entry prices)
python examples/st_petersburg_paradox.py

What’s Next

I’m excited to see how people use the Merton Share in practice. Future work could explore dynamic risk aversion (adjusting γ based on recent performance), multi-asset extensions, or Bayesian approaches to parameter uncertainty.

As always, contributions and feedback are welcome at github.com/wdm0006/keeks.

Additional Resources

For those interested in the theory:


Thanks for using Keeks! May your risk-adjusted returns be optimal.

Subscribe to the Newsletter

Get the latest posts and insights delivered straight to your inbox.