class backtide.sizers.KellyCriterion(win_rate, avg_win, avg_loss, fraction=0.25)
Kelly Criterion sizing.
Computes the theoretically optimal fraction of capital to risk for long-run
geometric growth: kelly_pct = win_rate - ((1 - win_rate) / (avg_win / avg_loss)),
then quantity = (equity * kelly_pct * fraction) / price. The fraction
multiplier (e.g., 0.25 for "quarter Kelly") tames drawdowns at the cost of
slower growth.
Parameters
win_rate : float
Historical fraction of winning trades, in [0, 1].
avg_win : float
Average profit of winning trades. Must be positive.
avg_loss : float
Average loss of losing trades, expressed as a positive number.
fraction : float
Kelly multiplier (typically 0.25–0.5 for half/quarter Kelly).
Current portfolio equity in the same currency as price.
When a sizer is attached to an order, the engine passes
equity converted to that instrument's quote currency.
price : float
Reference price of the instrument.
stop_distance : float | None, default=None
Distance from entry to stop loss, in price units.
atr : float | None, default=None
Current ATR value. Required for volatility-based sizers.
Returns
int | float
The number of units to trade. Positive for buys, negative for sells.