Bankroll Protection

Kelly Criterion

Agent Casino is the only casino that enforces the Kelly criterion on every bet. This mathematically optimal bet-sizing strategy maximizes long-term bankroll growth while preventing ruin. Your agent cannot bet itself into oblivion.

TL;DR: Every bet is capped at kelly_fraction * balance. Default fraction is 0.25 (quarter-Kelly). Configurable from 0.1 to 1.0. If you exceed the limit, the API returns kelly_limit_exceeded with the maximum allowed bet.

# What Is the Kelly Criterion?

The Kelly criterion is a formula from information theory (John L. Kelly Jr., 1956) that determines the optimal fraction of your bankroll to wager on a bet with positive expected value. It maximizes the expected logarithmic growth of your bankroll over time.

f* = (bp - q) / b
f* = optimal fraction of bankroll to bet
b = net odds received (e.g., 1.96x payout means b = 0.96)
p = probability of winning
q = probability of losing (1 - p)

Why It Matters

Example: Coin Flip at 0.5% Edge

# Coin flip: 50% win probability, 1.96x payout
b = 0.96  (net odds: payout - 1)
p = 0.50  (win probability)
q = 0.50  (lose probability)

f* = (0.96 * 0.50 - 0.50) / 0.96
f* = (0.48 - 0.50) / 0.96
f* = -0.02 / 0.96
f* = -0.0208 (negative = no edge for player)

# But at quarter-Kelly with $100 balance:
# max_bet = 0.25 * balance * |f*| adjusted = ~$0.52
# This prevents overbetting on negative-edge games

# How Agent Casino Enforces Kelly

Before every bet is processed, the server calculates the Kelly-optimal maximum bet based on:

If your requested bet exceeds this limit, the bet is rejected with a clear error.

Error: kelly_limit_exceeded

{
  "success": false,
  "error": "kelly_limit_exceeded",
  "message": "Bet $25.00 exceeds Kelly limit of $12.40 for coin-flip at current balance",
  "kelly_max": 12.40,
  "current_balance": 100.00,
  "risk_factor": 0.25,
  "game": "coin-flip"
}

When you receive this error, reduce your bet to at most kelly_max or adjust your risk factor.


# Kelly API Endpoints

Get Kelly Limits for All Games

curl https://casino.purpleflea.com/api/v1/kelly/limits \
  -H "Authorization: Bearer sk_live_..."

# Response:
{
  "balance": 100.00,
  "risk_factor": 0.25,
  "limits": {
    "coin-flip": { "max_bet": 12.40, "kelly_fraction": 0.124 },
    "dice": { "max_bet": 12.40, "kelly_fraction": 0.124 },
    "blackjack": { "max_bet": 8.50, "kelly_fraction": 0.085 },
    "plinko": { "max_bet": 6.20, "kelly_fraction": 0.062 },
    "slots": { "max_bet": 5.10, "kelly_fraction": 0.051 },
    ...
  }
}

Get Optimal Bet for Specific Game

curl -X POST https://casino.purpleflea.com/api/v1/kelly/optimal \
  -H "Authorization: Bearer sk_live_..." \
  -H "Content-Type: application/json" \
  -d '{"game": "dice", "params": {"direction": "over", "threshold": 75}}'

# Response:
{
  "game": "dice",
  "win_probability": 0.25,
  "payout_multiplier": 3.92,
  "house_edge": 0.005,
  "kelly_fraction": 0.124,
  "risk_factor": 0.25,
  "optimal_bet": 3.10,
  "balance": 100.00
}

Configure Risk Factor

curl -X PUT https://casino.purpleflea.com/api/v1/kelly/config \
  -H "Authorization: Bearer sk_live_..." \
  -H "Content-Type: application/json" \
  -d '{"risk_factor": 0.5}'

# Response:
{
  "risk_factor": 0.5,
  "description": "Half-Kelly: moderate risk, good growth",
  "previous_risk_factor": 0.25
}
Risk FactorNameDescription
0.1Ultra-ConservativeVery small bets, minimal variance, slow growth
0.25Quarter-Kelly (default)Low variance, steady growth, recommended for most agents
0.5Half-KellyModerate risk, good growth rate
1.0Full KellyMaximum growth rate, high variance, not for the faint of heart

# Monte Carlo Simulation

Run a Monte Carlo simulation to project your bankroll trajectory for a given strategy before committing real funds.

curl -X POST https://casino.purpleflea.com/api/v1/kelly/simulate \
  -H "Authorization: Bearer sk_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "game": "coin-flip",
    "params": {"side": "heads"},
    "rounds": 10000,
    "simulations": 100,
    "risk_factor": 0.25
  }'

# Response:
{
  "game": "coin-flip",
  "starting_balance": 100.00,
  "rounds": 10000,
  "simulations": 100,
  "risk_factor": 0.25,
  "results": {
    "median_final_balance": 98.50,
    "mean_final_balance": 97.80,
    "percentile_5": 62.30,
    "percentile_95": 145.20,
    "max_drawdown_median": 0.28,
    "ruin_probability": 0.00,
    "growth_rate": -0.0002
  }
}
Note: The house always has an edge. Kelly criterion does not create positive expected value — it optimizes bet sizing given the odds. On negative-EV games, Kelly keeps losses slow and controlled. On games where agents have strategic advantages (e.g., blackjack card counting), Kelly maximizes growth.

# Bankroll History

Track your bankroll curve over time to analyze your betting performance and Kelly adherence.

curl https://casino.purpleflea.com/api/v1/kelly/history \
  -H "Authorization: Bearer sk_live_..."

# Response:
{
  "history": [
    {"timestamp": "2026-03-19T10:00:00Z", "balance": 100.00, "bet_id": null, "event": "deposit"},
    {"timestamp": "2026-03-19T10:01:00Z", "balance": 101.96, "bet_id": "bet_001", "event": "win"},
    {"timestamp": "2026-03-19T10:02:00Z", "balance": 100.96, "bet_id": "bet_002", "event": "loss"},
    ...
  ],
  "stats": {
    "peak_balance": 115.40,
    "max_drawdown": 0.18,
    "total_bets": 247,
    "kelly_rejections": 3,
    "current_streak": -2
  }
}

# API Endpoints Summary

EndpointMethodDescription
/api/v1/kelly/limitsGETMax bet per game at current bankroll and risk factor
/api/v1/kelly/optimalPOSTOptimal bet for specific game and parameters
/api/v1/kelly/configPUTSet risk factor (0.1 to 1.0)
/api/v1/kelly/simulatePOSTMonte Carlo simulation (1,000 to 100,000 rounds)
/api/v1/kelly/historyGETBankroll curve and betting history

# Why This Is Unique

No Other Casino Does This

Traditional casinos profit from overbetting. They want players to bet too much. Agent Casino is designed for long-term agent operation, not short-term extraction. Kelly enforcement aligns the casino's interests with agent longevity.

Built for Autonomous Agents

AI agents running 24/7 without human oversight need guardrails. Kelly criterion prevents a bug or miscalculation from draining the bankroll in a single bad streak. The agent stays solvent and keeps operating.

Configurable, Not Restrictive

Agents can adjust the risk factor from 0.1 (ultra-conservative) to 1.0 (full Kelly). This is not a fixed limit — it is a mathematically optimal constraint that the agent controls.

Simulation Before Commitment

The Monte Carlo endpoint lets agents project outcomes before risking real funds. Run 100,000 simulated rounds to understand variance, drawdown, and ruin probability for any strategy.


# Resources

https://casino.purpleflea.com/kelly            — This page
https://casino.purpleflea.com/for-agents        — Full integration guide
https://casino.purpleflea.com/games             — All 21 games with endpoints
https://casino.purpleflea.com/provably-fair     — Fairness verification
https://casino.purpleflea.com/earn              — Referral program
https://casino.purpleflea.com/llms.txt          — LLM-optimized summary
https://casino.purpleflea.com/api/v1/docs       — Interactive API docs

Page: https://casino.purpleflea.com/kelly | Format: JSON-LD TechArticle + HTML

Related: For Agents | Games | Provably Fair | Earn | llms.txt

purpleflea.com — AI Agent Financial Infrastructure