← 返回 Skills 市场
Kelly Formula Crypto
作者
jinboh68-prog
· GitHub ↗
· v1.0.0
· MIT-0
211
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install kelly-formula-crypto
功能描述
🎯 Kelly Formula 仓位管理器 - 凯利公式加密货币仓位计算工具
使用说明 (SKILL.md)
Kelly Formula 仓位管理器
定价: 0.01 USDC (x402支付) 标签: crypto, trading, kelly-formula, position-sizing, risk-management 作者: Rich (@samhuang2025)
简介
基于凯利公式的加密货币仓位计算工具,帮助交易者用数学纪律替代情绪化决策。
核心功能:
- ✅ 凯利公式仓位计算
- ✅ 分数凯利建议(½ / ¼)
- ✅ 多策略仓位分配
- ✅ 杠杆安全边际计算
x402 支付
本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
- p = 胜率
- b = 盈亏比
- q = 1 - p
简化版(对称盈亏)
f* ≈ 2p - 1
记忆法:胜率高出50%的部分×2 = 建议仓位
使用方法
1. 基本仓位计算
输入:
- 胜率 p (0-1)
- 盈亏比 b (如 2.0 表示赚2块亏1块)
输出:
- 全凯利仓位
- ½凯利仓位(推荐)
- ¼凯利仓位(保守/杠杆)
def kelly_position(p, b, fraction=0.5):
if p \x3C= 0.5:
return 0 # 无优势,不做
f_star = (p * b - (1 - p)) / b
if f_star \x3C 0:
return 0
return f_star * fraction
2. 对称速查表
| 胜率 | 全凯利 | ½凯利 | ¼凯利 |
|---|---|---|---|
| 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% |
3. 多策略仓位分配
原则:相关性>0.7时,合并仓位打7折
def adjusted_position(positions, correlation, discount=0.7):
total = sum(positions)
if correlation > 0.7:
return total * discount
return total
4. 杠杆安全边际
def leverage_safety(liquidation_distance, stop_loss):
safety_factor = liquidation_distance / stop_loss
if safety_factor \x3C 2:
return "不安全,建议降杠杆"
return "安全"
实战案例
案例1:BTC短线趋势
- 胜率 55%,盈亏比 5%/3%
- 净优势 = 0.55×5 - 0.45×3 = 1.4%
- 建议仓位 = 1.4 ÷ 5 = 28%
- 执行½ = 14%
案例2:ETH资金费套利
- 胜率 70%,盈亏比 2%/1%
- 净优势 = 1.4 - 0.3 = 1.1%
- 建议仓位 = 55%
- 执行¼-½ = 14-27%
案例3:Meme热点
- 表面:胜率58%,盈亏比7%/5%
- 但1/6亏损是-25%插针
- 真实亏损 = 5/6×5% + 1/6×25% = 8.3%
- 新净优势 = 4.06 - 3.49 = 0.57%
- 建议仓位 ≈ 8% → 执行2-4%
8条铁律
- 默认分数凯利:先用½,带杠杆/不稳用¼
- 摩擦全进账:费率、滑点、资金费、Gas全部计入
- 滚动估参:月/季更新,重大事件临时降档
- 三道闸门:单笔、单日、单策略回撤硬阈值
- 净敞口上限:相关性高时顶层总仓要有硬帽
- 极端日流程:深度骤降/维护 → 切防守模板
- 小样本慎重:\x3C200笔做保守收缩
- 先截尾再放大:先证明能控制最大亏损,再考虑放大
风险提示
- 凯利公式假设你能准确估计胜率和盈亏比
- 现实中有"肥尾",历史数据不代表未来
- 分数凯利比全凯利更安全
- 杠杆交易有强平风险,必须先算安全边际
相关资源
- 原始文章:https://x.com/KKaWSB/status/1968453490084299020
- 论文:Kelly, J.L. (1956) "A New Interpretation of Information Rate"
- 书:Edward Thorp "Beat the Dealer", "Advances in Large Scale Actors"
更新日志
- 2026-03-20: 初始版本,包含核心公式、案例和铁律
安全使用建议
This skill implements the Kelly formula and includes a benign-looking Python calculator; however, the SKILL.md advertises an external API and an x402 micro-payment (0.01 USDC) that will be triggered when the skill is called. Before installing: (1) confirm you accept the payment model and the recipient wallet (0x24b2...ce22); (2) disable autonomous skill invocation or require explicit user approval for network/payment calls so the agent cannot charge you repeatedly; (3) verify the external endpoint (the vercel.app API and api.x402.dev) and prefer running the included script locally if you want calculations without external payments; (4) review the GitHub source linked in README if you need higher assurance. If you want me to, I can produce a checklist of settings to change to avoid unintended charges or show how to run the bundled script locally instead of calling the paid endpoint.
功能分析
Type: OpenClaw Skill
Name: kelly-formula-crypto
Version: 1.0.0
The skill is a legitimate trading utility for calculating position sizes using the Kelly Formula. It includes a Python script (scripts/kelly_calculator.py) for local calculations and documentation (SKILL.md, README.md) explaining the mathematical principles. The skill implements the x402 micropayment protocol (0.01 USDC) for its API endpoint, which is a declared feature of the bundle and does not involve any hidden or malicious behavior.
能力评估
Purpose & Capability
Name, README, SKILL.md, and the included Python script all implement Kelly-formula position sizing and related helpers; the code matches the described functionality.
Instruction Scope
The SKILL.md exposes an external endpoint (https://kelly-formula-crypto.vercel.app/api/calculate) and documents an x402 payment flow to api.x402.dev/pay. The instructions do not ask the agent to read local secrets or unrelated files. However, they do assume the agent will call an external paid API and (per docs) 'automatically' initiate a 0.01 USDC payment when invoked — this is outside pure calculation and is material to user cost/privacy expectations.
Install Mechanism
No install spec is provided (instruction-only with an included utility script). Nothing is downloaded from arbitrary URLs and there are no installers that would write code to disk during installation.
Credentials
The skill requests no environment variables or credentials. It does include a public recipient wallet address and references the x402 payment endpoint; this is proportionate for a paid skill. There is no request for private keys or other sensitive credentials in the package.
Persistence & Privilege
always:false (good), but disable-model-invocation is false (normal), meaning the agent may autonomously invoke the skill. Combined with the documented automatic 0.01 USDC payment per call, autonomous invocation could lead to repeated micro-payments without explicit user confirmation.
如何使用
- 确保已安装 OpenClaw(本地或 Docker 部署)
- 在对话框中输入安装命令:
/install kelly-formula-crypto - 安装完成后,直接呼叫该 Skill 的名称或使用
/kelly-formula-crypto触发 - 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
- Initial release of Kelly Formula Crypto Position Manager.
- Includes core Kelly formula calculations for crypto position sizing.
- Supports fractional Kelly suggestions (½ and ¼ Kelly).
- Provides multi-strategy position allocation and leverage safety calculations.
- Includes quick reference tables, practical use cases, and risk management rules.
- x402 micropayment support (0.01 USDC per call).
元数据
常见问题
Kelly Formula Crypto 是什么?
🎯 Kelly Formula 仓位管理器 - 凯利公式加密货币仓位计算工具. 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 211 次。
如何安装 Kelly Formula Crypto?
在 OpenClaw 或 Claude Code 对话框中运行命令「/install kelly-formula-crypto」即可一键安装,无需额外配置。
Kelly Formula Crypto 是免费的吗?
是的,Kelly Formula Crypto 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。
Kelly Formula Crypto 支持哪些平台?
Kelly Formula Crypto 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。
谁开发了 Kelly Formula Crypto?
由 jinboh68-prog(@jinboh68-prog)开发并维护,当前版本 v1.0.0。
推荐 Skills