Calculate investment position size using the Kelly formula. Use when a user asks about position sizing, capital allocation, position sizing or the Kelly formula. Supports full Kelly, fractional Kelly and portfolio/combination optimization.
使用Kelly公式计算最优投资仓位,平衡长期增长与风险控制。
完整Kelly: f* = (bp - q) / b
b = 盈亏比 (平均盈利/平均亏损)p = 胜率, q = 败率 (1-p)f* = 最优仓位比例简化Kelly: f = μ / σ² (基于期望收益μ和方差σ²)
当用户提供胜率和盈亏比时,计算完整Kelly并应用1/4分数:
let kelly = (b * p - (1.0 - p)) / b;
let safe_kelly = (kelly * 0.25).min(0.25).max(0.0);