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.0.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.0-py3-none-any.whl (3.1 kB view details)

Uploaded Python 3

File details

Details for the file mcp_server_stock_hedge-0.1.0.tar.gz.

File metadata

  • Download URL: mcp_server_stock_hedge-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 458f3d6f675565ad8dc0679f991fc75877e2e517a17abdbe94f361b0a5d0ab7e
MD5 8d2e98b63c07ce606c4e5abb5e2ac988
BLAKE2b-256 9616c935143f14d2f04f614cf1b669f5414972bda5e34d552a77fcfc94ed91b2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mcp_server_stock_hedge-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 99beaca8abd63a1796dd02a8a262144e871b097f87d6c01893150081832ee46a
MD5 a4fb45f12857f5d503735b24ea34775d
BLAKE2b-256 a34a260e4d9df2279279c1a7f6034799bf1992c4a1e71b69633c486eee51cfba

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