A BSM-based stock and futures hedge ratio calculator for MCP.
Project description
mcp-server-stock-hedge
一个基于 Model Context Protocol (MCP) 的金融量化工具包,专门用于计算 Black-Scholes-Merton (BSM) 模型下的期权 Delta 及其对应的股票与期货对冲配比。
🌟 功能特性
- BSM 定价引擎:精确计算欧式期权的理论 Delta 值。
- 对冲比例建议:直接输出为实现 Delta 中性所需的标的资产(股票或期货)操作数量。
- 灵活参数:支持自定义执行价、到期时间、波动率、无风险利率及合约乘数。
- AI 友好:深度优化了工具描述,方便大模型(如 Claude, GPT)进行函数调用(Tool Calling)。
🛠 技术原理
工具核心使用 BSM 模型计算 Delta ($\Delta$):
$$d_1 = \frac{\ln(S/K) + (r + \sigma^2/2)T}{\sigma\sqrt{T}}$$
对于看涨期权(Call): $$\Delta = N(d_1)$$
对于看跌期权(Put): $$\Delta = N(d_1) - 1$$
对冲比例依据 $\Delta$ 与合约乘数(Contract Size)动态生成。
🚀 安装与准备
本工具推荐使用 uv 进行管理。
1. 环境要求
- Python 3.10+
- 安装
uv:curl -LsSf [https://astral.sh/uv/install.sh](https://astral.sh/uv/install.sh) | sh
2. 本地测试
在发布到 PyPI 前,你可以在本地运行以下命令验证:
uvx --from . mcp-server-stock-hedge
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mcp_server_stock_hedge-0.1.1.tar.gz.
File metadata
- Download URL: mcp_server_stock_hedge-0.1.1.tar.gz
- Upload date:
- Size: 2.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1219a258ec5dc0479e6c723fd186192d23cf863b95e5977cab996d250902e5fe
|
|
| MD5 |
498bc30ed3e5727ae77a2976b22a4750
|
|
| BLAKE2b-256 |
5c441586ca2de40eae546d5dbff5c92942331c53fd579e57ab653106945bc04e
|
File details
Details for the file mcp_server_stock_hedge-0.1.1-py3-none-any.whl.
File metadata
- Download URL: mcp_server_stock_hedge-0.1.1-py3-none-any.whl
- Upload date:
- Size: 3.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8a1a9faf42a6d87690602644bcfab6bf4fc62685f684f4a62e87751bcd3dfcd2
|
|
| MD5 |
2f209e1efe3705a68bae91b1acd9d634
|
|
| BLAKE2b-256 |
ca7cfa838e993f05c222e445d1a94223920ecd90b9005ed1d2adfb803f4e7d21
|