w

walkingshamrock

@walkingshamrock/black-scholes-mcp
0 Stars 353 次浏览 walkingshamrock 更新于 2026-08-23
该服务暂未提供标准配置,请参考 README 手动接入

服务介绍

Black-Scholes MCP 服务器

该项目提供了一个使用 Black-Scholes 模型计算欧式期权价格和希腊字母的模型上下文协议 (MCP) 服务器。

功能

  • 计算欧式看涨和看跌期权的 Black-Scholes 价格
  • 计算期权希腊字母及高阶希腊字母:
    • Delta
    • Vega
    • Theta
    • Gamma
    • Rho
    • Lambda
    • Epsilon
    • Vanna
    • Charm
    • Vomma
    • Veta
    • Speed
    • Zomma
    • Color
    • Ultima
    • Vera

使用方法

安装与使用

  1. 安装依赖(如果使用 uv):
    sh
    uv pip install -r requirements.txt

    或者使用您偏好的 Python 包管理器。

  2. 将此 MCP 服务器安装到 Claude:
    sh
    uv run mcp install main.py

    该命令会将配置添加到 claude_desktop_config.json 中,以便 Claude 可以使用此 MCP 服务器。

  3. (可选)直接运行 MCP 服务器:
    sh
    python main.py

  4. 使用 MCP 工具通过提供以下参数来计算期权价格和希腊字母:

    • S: 标的价格
    • K: 行权价
    • T: 到期时间(年)
    • r: 无风险利率(年化,小数形式)
    • q: 股息率(年化,小数形式)
    • vol: 波动率(年化,小数形式)
    • type: "call" 或 "put"

运行测试

要运行此项目的测试:

  1. 以开发模式安装包:
    sh
    pip install -e .

  2. 使用 unittest 运行测试:
    sh
    python -m unittest discover -s tests

    或者使用 pytest(在从 requirements.txt 安装 pytest 后):
    sh
    python -m pytest

  3. 运行特定的测试模块:
    sh
    python -m unittest tests.calculators.test_black_scholes_price

    或者使用 pytest:
    sh
    python -m pytest tests/calculators/test_black_scholes_price.py

致谢

本项目使用 modelcontextprotocol/python-sdk 来实现 MCP 服务器。

许可证

本项目采用 MIT 许可证。详情请参阅 LICENSE

相关 MCP 服务