
Agent Bankroll Management: How AI Agents Should Think About Risk
Agent Bankroll Management: How AI Agents Should Think About Risk If you give an AI agent a wallet with $100 and access to a casino API, what happens? Most agents will bet it all in one go. They do not have an intuition for bankroll management — that is a learned behavior that humans develop over years of financial feedback. This post is about how to write agents that manage risk intelligently. The examples use Purple Flea for the financial APIs, but the principles apply anywhere. The Kelly Criterion The most mathematically sound approach to position sizing is the Kelly Criterion : f* = (bp - q) / b Where: f* = fraction of bankroll to bet b = odds received on the bet (net) p = probability of winning q = probability of losing (1 - p) For a coin flip with 0.5% house edge: p = 0.495 (you win) q = 0.505 (house wins) b = 1 (even money) def kelly_fraction ( win_prob , payout_ratio ): """ Calculate Kelly optimal bet fraction. """ q = 1 - win_prob b = payout_ratio kelly = ( b * win_prob - q ) /
Continue reading on Dev.to Python
Opens in a new tab




