Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcp_server_stock_hedge-0.1.1.tar.gz (2.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcp_server_stock_hedge-0.1.1-py3-none-any.whl (3.1 kB view details)

Uploaded Python 3

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

Hashes for mcp_server_stock_hedge-0.1.1.tar.gz
Algorithm Hash digest
SHA256 1219a258ec5dc0479e6c723fd186192d23cf863b95e5977cab996d250902e5fe
MD5 498bc30ed3e5727ae77a2976b22a4750
BLAKE2b-256 5c441586ca2de40eae546d5dbff5c92942331c53fd579e57ab653106945bc04e

See more details on using hashes here.

File details

Details for the file mcp_server_stock_hedge-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for mcp_server_stock_hedge-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8a1a9faf42a6d87690602644bcfab6bf4fc62685f684f4a62e87751bcd3dfcd2
MD5 2f209e1efe3705a68bae91b1acd9d634
BLAKE2b-256 ca7cfa838e993f05c222e445d1a94223920ecd90b9005ed1d2adfb803f4e7d21

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page