Install
openclaw skills install kelly-formula-crypto🎯 Kelly Formula 仓位管理器 - 凯利公式加密货币仓位计算工具
openclaw skills install kelly-formula-crypto定价: 0.01 USDC (x402支付) 标签: crypto, trading, kelly-formula, position-sizing, risk-management 作者: Rich (@samhuang2025)
基于凯利公式的加密货币仓位计算工具,帮助交易者用数学纪律替代情绪化决策。
核心功能:
本skill支持x402微支付协议。调用时自动发起0.01 USDC支付请求。
# x402支付示例
curl -X POST https://api.x402.dev/pay \
-H "Content-Type: application/json" \
-d '{
"to": "0x24b288c98421d7b447c2d6a6442538d01c5fce22",
"amount": "0.01",
"currency": "USDC",
"memo": "kelly-formula-skill"
}'
f* = (bp - q) / b
f* ≈ 2p - 1
记忆法:胜率高出50%的部分×2 = 建议仓位
输入:
输出:
def kelly_position(p, b, fraction=0.5):
if p <= 0.5:
return 0 # 无优势,不做
f_star = (p * b - (1 - p)) / b
if f_star < 0:
return 0
return f_star * fraction
| 胜率 | 全凯利 | ½凯利 | ¼凯利 |
|---|---|---|---|
| 52% | 4% | 2% | 1% |
| 55% | 10% | 5% | 2.5% |
| 60% | 20% | 10% | 5% |
| 65% | 30% | 15% | 7.5% |
| 70% | 40% | 20% | 10% |
| 75% | 50% | 25% | 12.5% |
原则:相关性>0.7时,合并仓位打7折
def adjusted_position(positions, correlation, discount=0.7):
total = sum(positions)
if correlation > 0.7:
return total * discount
return total
def leverage_safety(liquidation_distance, stop_loss):
safety_factor = liquidation_distance / stop_loss
if safety_factor < 2:
return "不安全,建议降杠杆"
return "安全"