home / skills / louloulin / claude-agent-sdk / kelly-position-sizing

kelly-position-sizing skill

/.claude/skills/kelly-position-sizing

This skill applies the Kelly criterion to position sizing, optimizing long-term capital growth through mathematically driven risk-aware allocation.

npx playbooks add skill louloulin/claude-agent-sdk --skill kelly-position-sizing

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
11.8 KB
---
id: kelly-position-sizing
name: Kelly准则仓位管理
description: 基于Kelly准则的科学仓位管理,优化长期资本增长率
version: 1.0.0
author: InvestIntel AI Team
dependencies:
  - financial-data
  - valuation-framework
tags:
  - position-sizing
  - kelly-criterion
  - risk-management
  - portfolio-optimization
  - money-management
---

# Kelly准则仓位管理

**作者**: InvestIntel AI Team
**版本**: 1.0.0
**最后更新**: 2026-01-11
**标签**: position-sizing, kelly-criterion, risk-management, portfolio-optimization
**依赖**: [financial-data, valuation-framework]

---

## 📖 技能描述

基于Kelly准则的科学仓位管理系统,通过数学优化确定最佳仓位大小,最大化长期资本增长率。

### 核心理念

1. **数学最优** - Kelly准则给出理论最优仓位
2. **长期增长** - 最大化几何平均收益率
3. **风险控制** - 避免破产,平滑波动
4. **实践调整** - 理论与现实的平衡

### Kelly准则历史

- **1956年**: John L. Kelly Jr. 在贝尔实验室发明
- **1960年代**: Ed Thorp在21点中应用,后来用于期权交易
- **1980年代**: Jim Simons在文艺复兴科技使用
- **现状**: 对冲基金广泛使用的资金管理工具

---

## 🧮 Kelly准则基础

### 简单Kelly公式

最简单的Kelly公式(二元结果):

```
f* = (bp - q) / b
```

其中:
- `f*` = 最佳仓位比例(资本百分比)
- `b` = 赔率(盈亏比)
- `p` = 胜率(获胜概率)
- `q` = 败率(1 - p)

### 示例计算

**示例1: 60%胜率, 1:1赔率**
```
b = 1.0
p = 0.60
q = 0.40

f* = (1.0 × 0.60 - 0.40) / 1.0 = 0.20
```
**结论**: 20%仓位

**示例2: 51%胜率, 1:1赔率**
```
f* = (1.0 × 0.51 - 0.49) / 1.0 = 0.02
```
**结论**: 2%仓位(优势很小)

**示例3: 75%胜率, 2:1赔率**
```
b = 2.0
p = 0.75
q = 0.25

f* = (2.0 × 0.75 - 0.25) / 2.0 = 0.625
```
**结论**: 62.5%仓位(极佳机会)

### 连续收益率Kelly公式

适用于投资(收益率连续分布):

```
f* = μ / σ²
```

其中:
- `μ` = 预期超额收益率(收益率 - 无风险利率)
- `σ²` = 收益率方差

#### 修正Kelly(考虑偏度):

```
f* = μ / σ² - (skewness / 6)
```

### 多资产Kelly公式

投资组合优化:

```
max: μ'w - (λ/2) w'Σw
```

其中:
- `w` = 权重向量
- `μ` = 期望收益向量
- `Σ` = 协方差矩阵
- `λ` = 风险厌恶系数(Kelly取λ=1)

---

## 🎯 实践Kelly策略

### 1. Full Kelly vs Fractional Kelly

#### Full Kelly (全Kelly)
```yaml
优点:
  - 理论最优,最大化长期增长率
  - 适合确定性高的机会

缺点:
  - 短期波动极大
  - 心理难以承受
  - 估计误差敏感

适用场景:
  - 套利机会
  - 高胜率+高赔率
  - Ed Thorp级别分析能力
```

#### Half Kelly (半Kelly)
```yaml
f_half = 0.5 × f_full

优点:
  - 大幅降低波动
  - 长期增长仅降低25%
  - 心理舒适度提升

适用场景:
  - 大多数投资机会
  - 普通投资者
  - 不确定性中等

历史实践:
  - Ed Thorp: 主要用半Kelly
  - 许多对冲基金: 1/4到1/2 Kelly
```

#### Quarter Kelly (四分之一Kelly)
```yaml
f_quarter = 0.25 × f_full

优点:
  - 极度保守
  - 几乎不会大幅回撤
  - 长期增长降低50%

适用场景:
  - 学习阶段
  - 不确定性高
  - 退休账户
```

### Kelly级别选择指南

```yaml
确定性水平 | Kelly倍数 | 应用场景
-----------|----------|----------
极极高     | 1.0x     | 套利,错误定价
极高       | 0.75x    | 深度研究+长期跟踪
高         | 0.5x     | Lollapalooza机会
中等       | 0.25x    | 标准价值投资
低         | 0.125x   | 投机性仓位
极低       | 0x       | 不投资
```

### 2. Kelly + MPT混合

**现代投资组合理论(MPT)**:
```
max: μ'w - (λ/2) w'Σw
```

**Kelly准则**:
```
max: μ'w - (1/2) w'Σw
```

**混合方法**:
```yaml
步骤1: 用MPT找到有效前沿
步骤2: 在有效前沿上用Kelly确定风险水平
步骤3: 根据信心调整Kelly分数

公式: w_final = k × w_kelly
       其中 k ∈ [0, 1]
```

### 3. 动态Kelly调整

#### 基于波动率的调整

```python
# 当市场波动率上升时降低仓位
def dynamic_kelly(base_kelly, current_vol, avg_vol):
    vol_ratio = current_vol / avg_vol
    adjustment = 1 / vol_ratio
    return base_kelly × adjustment

# 示例:
# 基础Kelly = 20%
# 当前波动率 = 30%, 平均波动率 = 20%
# 调整后Kelly = 20% × (20%/30%) = 13.3%
```

#### 基于相关性的调整

```python
# 新仓位与现有组合的相关性
def correlation_adjustment(kelly, correlation):
    # 高相关性 → 降低仓位
    if correlation > 0.7:
        return kelly × 0.5
    elif correlation > 0.4:
        return kelly × 0.7
    else:
        return kelly

# 示例:
# 基础Kelly = 15%
# 与持仓相关性 = 0.8
# 调整后Kelly = 15% × 0.5 = 7.5%
```

#### 基于集中度的调整

```python
# 已用仓位越多,新仓位越小
def concentration_adjustment(kelly, total_position):
    used_capital = sum(total_position)
    remaining = 1.0 - used_capital

    # 确保总仓位不超过100%
    if kelly > remaining:
        return remaining
    return kelly

# 示例:
# 基础Kelly = 20%
# 已用仓位 = 85%
# 调整后Kelly = min(20%, 15%) = 15%
```

---

## 📊 Kelly计算实例

### 实例1: 价值投资机会

**投资分析**:
- 当前价格: $80
- 内在价值: $100
- 1年期目标价: $100
- 最坏情况: $60
- 最好情况: $120

**情景分析**:
```yaml
情景    概率   价格    收益率
下跌    20%    $60     -25%
持平    30%    $80      0%
上涨    40%    $100    +25%
大涨    10%    $120    +50%
```

**计算**:
```
μ = 0.20×(-0.25) + 0.30×0 + 0.40×0.25 + 0.10×0.50
  = -0.05 + 0 + 0.10 + 0.05
  = 0.10 (10%)

σ² = 0.20×(-0.25-0.10)² + 0.30×(0-0.10)² +
     0.40×(0.25-0.10)² + 0.10×(0.50-0.10)²
  = 0.0245 + 0.003 + 0.009 + 0.016
  = 0.0525

f* = μ / σ² = 0.10 / 0.0525 = 1.90
```

**应用实践调整**:
```yaml
Full Kelly: 190% → 限制在100%
Half Kelly: 95%
Quarter Kelly: 47.5%

推荐: 使用Quarter Kelly → 45%仓位
理由: 估计误差+相关性+风险偏好
```

### 实例2: 护城河+低估

**投资分析**:
- ROIC = 18%
- 预期增长 = 8%
- P/E = 12
- 安全边际 = 35%
- 护城河评分 = 8/10

**参数估计**:
```yaml
预期收益:
  - 估值修复: 35% (安全边际)
  - 盈利增长: 8%
  - 分红: 2%
  - 总预期: 45%

风险(标准差):
  - 历史波动率: 25%
  - 行业波动率: 30%
  - 估计: 28%

无风险利率: 4%
```

**计算**:
```
μ = 45% - 4% = 41%
σ² = (28%)² = 7.84%

f* = 0.41 / 0.0784 = 5.23
```

**实践调整**:
```yaml
Full Kelly: 523% → 远超100%
Half Kelly: 261% → 超过100%
Quarter Kelly: 130% → 超过100%

推荐: 限制在40%
理由:
  1. 估计误差巨大
  2. Kelly对误差极敏感
  3. Munger式集中投资上限
```

### 实例3: 低确定性机会

**投资分析**:
- 成长股,未盈利
- 市场规模巨大
- 产品未验证
- 管理层优秀

**情景分析**:
```yaml
情景      概率    收益率
完全失败  40%     -100%
小幅盈利  30%     +50%
成功      20%     +200%
大成功    10%     +500%
```

**计算**:
```
μ = 0.40×(-1) + 0.30×0.5 + 0.20×2 + 0.10×5
  = -0.40 + 0.15 + 0.40 + 0.50
  = 0.65 (65%)

σ² = 0.40×(-1-0.65)² + 0.30×(0.5-0.65)² +
     0.20×(2-0.65)² + 0.10×(5-0.65)²
  ≈ 1.1 + 0.007 + 0.036 + 0.19
  ≈ 1.33

f* = 0.65 / 1.33 = 0.49 (49%)
```

**实践调整**:
```yaml
Full Kelly: 49%
Half Kelly: 24.5%
Quarter Kelly: 12.25%

推荐: 使用1/8 Kelly → 6%
理由:
  1. 极不确定(未盈利公司)
  2. 估计误差可能极大
  3. 破产风险真实存在
  4. 学习阶段,小额试探
```

---

## ⚠️ Kelly准则的局限性

### 1. 估计误差敏感性

**问题**: Kelly对μ和σ²极度敏感
```yaml
μ估计偏差 10% → f*偏差可达 50%+
σ²估计偏差 10% → f*偏差可达 20%+

解决:
  - 使用保守估计
  - 应用fractional Kelly
  - 定期重新估计
```

### 2. 非正态分布

**问题**: 真实收益率常有肥尾
```yaml
黑天鹅事件:
  - 2008: -50%
  - 2020: -34%(快速恢复)

解决:
  - 压力测试
  - 尾部风险对冲
  - 更保守的Kelly分数
```

### 3. 流动性约束

**问题**: 理论假设可以随时交易
```yaml
现实约束:
  - 买卖价差
  - 市场冲击
  - 交易限制

解决:
  - 降低名义Kelly
  - 使用分批建仓
  - 考虑流动性折扣
```

### 4. 心理因素

**问题**: 理论假设理性
```yaml
实际挑战:
  - 回撤时恐慌
  - 加仓时恐惧
  - 长期仓位难以坚持

解决:
  - 使用fractional Kelly
  - 事先制定规则
  - 定期回顾心理
```

---

## 🔧 实施指南

### 步骤1: 估计参数

```yaml
对于每个投资机会:

1. 预期收益率(μ):
   - 估值修复
   - 盈利增长
   - 分红收益
   - 减去无风险利率

2. 风险(σ²):
   - 历史波动率
   - 行业波动率
   - 情景分析

3. 置信度:
   - 信息质量
   - 分析深度
   - 跟踪时间
```

### 步骤2: 计算基础Kelly

```python
import numpy as np

def calculate_kelly(expected_return, variance):
    """
    计算基础Kelly仓位
    """
    kelly = expected_return / variance
    return min(kelly, 1.0)  # 限制在100%

# 示例
mu = 0.15  # 15%超额收益
sigma2 = 0.0625  # 25%标准差的平方

kelly = calculate_kelly(mu, sigma2)
print(f"基础Kelly: {kelly:.1%}")
```

### 步骤3: 应用调整

```python
def adjust_kelly(base_kelly,
                 confidence='medium',
                 correlation=0.0,
                 used_capital=0.0,
                 current_vol=None,
                 avg_vol=None):

    kelly = base_kelly

    # 1. 置信度调整
    confidence_multipliers = {
        'very_high': 0.75,
        'high': 0.5,
        'medium': 0.25,
        'low': 0.125,
        'very_low': 0.0
    }
    kelly *= confidence_multipliers[confidence]

    # 2. 相关性调整
    if correlation > 0.7:
        kelly *= 0.5
    elif correlation > 0.4:
        kelly *= 0.7

    # 3. 集中度调整
    remaining = 1.0 - used_capital
    kelly = min(kelly, remaining)

    # 4. 波动率调整
    if current_vol and avg_vol:
        vol_ratio = current_vol / avg_vol
        kelly /= vol_ratio

    return max(kelly, 0.0)

# 示例
adjusted = adjust_kelly(
    base_kelly=0.40,
    confidence='high',
    correlation=0.3,
    used_capital=0.60,
    current_vol=0.22,
    avg_vol=0.20
)

print(f"调整后Kelly: {adjusted:.1%}")
```

### 步骤4: 执行与监控

```yaml
执行:
  1. 分批建仓(避免择时)
  2. 设置止损(极端保护)
  3. 定期再平衡

监控:
  1. 每季度重新估计μ和σ²
  2. 实际结果 vs 预期
  3. Kelly分数调整

回顾:
  1. Kelly预测准确吗?
  2. 调整因子有效吗?
  3. 心理承受如何?
```

---

## 📈 Kelly vs 其他方法

| 方法 | 优点 | 缺点 | 适用 |
|------|------|------|------|
| **等权重** | 简单,分散好 | 忽视机会差异 | 被动投资 |
| **市值权重** | 流动性好 | 追涨杀跌 | 指数投资 |
| **风险平价** | 风险均衡 | 需要杠杆 | 全天候策略 |
| **MPT** | 理论完善 | 估计误差大 | 机构配置 |
| **Kelly** | 长期最优 | 波动大,估计敏感 | 主动投资 |

### 综合建议

```yaml
初级投资者:
  - 等权重 + 行业分散
  - 避免单一股票超20%

中级投资者:
  - Kelly + 风险平价混合
  - Quarter Kelly为主

高级投资者:
  - Full Kelly(少数机会)
  - Half Kelly(多数机会)
  - 动态调整
```

---

## 🔗 相关资源

### 经典著作
- "Fortune's Formula" - William Poundstone
- "Kelly Capital Growth Investment Criterion" - Leonard MacLean
- Ed Thorp论文和访谈

### 相关技能
- [Munger多元思维模型](../munger-mental-models/SKILL.md)
- [Graham深度价值投资](../graham-value-investing/SKILL.md)
- [Buffett质量价值投资](../buffett-quality-value/SKILL.md)

---

## 📝 变更历史

### v1.0.0 (2026-01-11)
- 初始版本
- 实现Kelly公式计算
- 实现fractional Kelly策略
- 实现动态调整方法
- 实践案例和限制分析

Overview

This skill implements position sizing based on the Kelly criterion to optimize long-term capital growth. It provides formulas, practical adjustments, and portfolio-level extensions to translate theoretical Kelly fractions into actionable trade sizes. The focus is on maximizing geometric growth while controlling short-term risk through fractional Kelly, volatility, correlation, and concentration adjustments.

How this skill works

It computes base Kelly fractions from expected excess return and return variance (f* = μ/σ²) or the discrete-binary formula for bet-like outcomes. The skill applies practical caps and multipliers (half, quarter, etc.) and supports multi-asset optimization using μ'w - (1/2) w'Σw. Dynamic adjustments account for volatility, correlation with existing holdings, used capital, and confidence levels. It includes monitoring guidance to re-estimate parameters and rebalance.

When to use it

  • Sizing positions when you have quantified expected excess return and variance
  • Allocating capital across multiple opportunities with known covariances
  • Converting theoretical optimal bets into conservative trade sizes (fractional Kelly)
  • Adjusting exposure during regime changes (rising volatility or concentration)
  • Stress-testing portfolios and setting practical caps to avoid ruin

Best practices

  • Use conservative parameter estimates and prefer fractional Kelly (1/2, 1/4, 1/8) for noisy signals
  • Cap nominal position sizes (e.g., 100% of portfolio) and enforce remaining-capital checks
  • Adjust Kelly by realized vs average volatility and by correlation to existing portfolio
  • Recalculate μ and σ² regularly and run scenario/ tail stress tests for fat tails
  • Implement execution rules: build in tranches, set stop loss thresholds, and log deviations

Example use cases

  • A value investor estimating scenario-based μ and σ² to derive a conservative quarter-Kelly position
  • A quant allocating across assets using multi-asset Kelly with a covariance matrix and risk constraints
  • A trader reducing base Kelly when current market volatility exceeds historical averages
  • A portfolio manager limiting new positions to remaining capital after accounting for existing exposures
  • A venture investor using 1/8 Kelly for highly uncertain startups to preserve capital while testing ideas

FAQ

Does Kelly ignore tail risk and liquidity constraints?

Kelly assumes repeatable bets and often underestimates tails and market impact; mitigate by stress-testing, adding tail hedges, lowering Kelly multiples, and accounting for liquidity discounts.

How do I pick a fractional Kelly multiplier?

Choose based on confidence: very high (0.75x), high (0.5x), medium (0.25x), low (0.125x). Lower multipliers reduce volatility and estimation sensitivity.