核心思想

Kelly 准则 (Kelly Criterion) 确定在每次交易中使用多少资金,使得长期复利最大化。

f=bpqb=pqbf^* = \frac{bp - q}{b} = p - \frac{q}{b}

其中 pp 为胜率,q=1pq = 1-p 为败率,bb 为赔率(盈亏比)。

对于更一般的场景: f=E[R]2σR2f^* = \frac{E[R]}{2\sigma_R^2}

Fractional Kelly — 保守版

实际使用中,全仓 Kelly (f=1f=1) 波动过大。实践中常用 Fractional Kelly:

ffrac=λf其中 λ[0.25,0.5]f_{\text{frac}} = \lambda \cdot f^* \quad \text{其中 } \lambda \in [0.25, 0.5]

Python 实现

import numpy as np
from scipy import optimize

def kelly_fraction(win_rate, avg_win, avg_loss):
    """计算 Kelly 最优比例"""
    b = avg_win / avg_loss if avg_loss > 0 else np.inf
    p = win_rate
    return (b * p - (1 - p)) / b

def empirical_kelly(returns, fraction=1.0):
    """从历史收益计算 Kelly"""
    win_rate = np.mean(returns > 0)
    avg_win = np.mean(returns[returns > 0]) if win_rate > 0 else 0
    avg_loss = np.mean(np.abs(returns[returns < 0])) if (1-win_rate) > 0 else 1
    
    f_star = kelly_fraction(win_rate, avg_win, avg_loss)
    return fraction * max(f_star, 0)

# 模拟不同 Kelly 倍数的长期增长
def simulate_kelly(returns_history, fractions=[0.25, 0.5, 1.0], N_periods=1000):
    results = {}
    for frac in fractions:
        equity = 1.0
        position_history = []
        for r in returns_history:
            f = frac * kelly_fraction_from_returns(returns_history)
            equity *= (1 + f * r)
            position_history.append(f)
        results[f'kelly_{frac}x'] = {
            'final_equity': equity,
            'cagr': equity ** (1/N_periods) - 1,
            'max_drawdown': max_pos_drawdown(position_history, equity)
        }
    return results

局限与风险

变体

版本描述
Full Kellyf=ff = f^*,理论最优但波动大
Half Kellyλ=0.5\lambda = 0.5,半仓 Kelly(最常用)
Quarter Kellyλ=0.25\lambda = 0.25,保守版
Volatility-adjusted Kellyf=μ/(γσ2)f^* = \mu / (\gamma \sigma^2),风险调整版
Kelly + Correlation多资产相关调整

参考文献

  1. Kelly, J.L., 1956. “A New Interpretation of Information Rate.” Bell System Technical Journal.
  2. Thorp, E.O., 2008. “The Kelly Criterion in Blackjack, Sports Betting, and the Stock Market.”
  3. MacLean, L., Thorp, E. & Ziemba, W., 2011. The Kelly Criterion in Investment, Sports, Gambling.