walkingshamrock
服务介绍
Black-Scholes MCP 服务器
该项目提供了一个使用 Black-Scholes 模型计算欧式期权价格和希腊字母的模型上下文协议 (MCP) 服务器。
功能
- 计算欧式看涨和看跌期权的 Black-Scholes 价格
- 计算期权希腊字母及高阶希腊字母:
- Delta
- Vega
- Theta
- Gamma
- Rho
- Lambda
- Epsilon
- Vanna
- Charm
- Vomma
- Veta
- Speed
- Zomma
- Color
- Ultima
- Vera
使用方法
安装与使用
-
安装依赖(如果使用
uv):
sh
uv pip install -r requirements.txt或者使用您偏好的 Python 包管理器。
-
将此 MCP 服务器安装到 Claude:
sh
uv run mcp install main.py该命令会将配置添加到
claude_desktop_config.json中,以便 Claude 可以使用此 MCP 服务器。 -
(可选)直接运行 MCP 服务器:
sh
python main.py -
使用 MCP 工具通过提供以下参数来计算期权价格和希腊字母:
S: 标的价格K: 行权价T: 到期时间(年)r: 无风险利率(年化,小数形式)q: 股息率(年化,小数形式)vol: 波动率(年化,小数形式)type: "call" 或 "put"
运行测试
要运行此项目的测试:
-
以开发模式安装包:
sh
pip install -e . -
使用 unittest 运行测试:
sh
python -m unittest discover -s tests或者使用 pytest(在从 requirements.txt 安装 pytest 后):
sh
python -m pytest -
运行特定的测试模块:
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。