
StockFlow MCP Server

2025.02.24
10
Python股票数据期权分析金融分析金融服务
StockFlow MCP Server 是一个基于 Model Context Protocol (MCP) 的服务,提供实时股票数据和期权分析功能。该服务通过 Yahoo Finance 获取市场数据,使 LLMs(大型语言模型)能够访问市场数据、分析股票并评估期权策略。
View on GitHub
Overview
基本能力
产品定位
StockFlow MCP Server 是一个金融数据服务,专注于提供实时股票数据和期权分析,适用于金融分析、投资决策和市场研究。
核心功能
- 股票数据
- 实时股票价格和关键指标
- 包含 OHLC 值的历史价格数据
- 公司基本面和财务报表
-
市场指标和比率
-
期权分析
- 完整的期权链数据
- Greeks(delta, gamma, theta, vega)
- 成交量和未平仓合约跟踪
- 期权策略分析
适用场景
- 实时股票数据查询
- 历史价格分析
- 期权策略评估
- 金融研究和投资决策
工具列表
get-stock-data
- 获取当前价格和成交量
- 市值和市盈率
-
52周高/低点
-
get-historical-data
- OHLC 价格
- 可配置的时间周期
-
成交量数据
-
get-options-chain
- 看涨和看跌期权
- 行权价格
- Greeks 和隐含波动率
- 成交量和未平仓合约
常见问题解答
- 数据来源于 Yahoo Finance,可能存在延迟
- 期权数据的可用性取决于市场交易时间
- 受 Yahoo Finance API 限制,存在速率限制
使用教程
使用依赖
# 安装依赖
pip install mcp yfinance
安装教程
- 克隆仓库:
git clone https://github.com/twolven/mcp-stockflow.git
cd mcp-stockflow
- 安装依赖:
pip install -r requirements.txt
- 添加到 Claude 配置:
在
claude-desktop-config.json
的mcpServers
部分添加以下内容:
{
"mcpServers": {
"stockflow": {
"command": "python",
"args": ["path/to/stockflow.py"]
}
}
}
调试方式
运行服务器:
python stockflow.py
使用 MCP 客户端:
from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client
server_params = StdioServerParameters(
command="python",
args=["stockflow.py"]
)
async def run():
async with stdio_client(server_params) as (read, write):
async with ClientSession(read, write) as session:
await session.initialize()
# 获取当前股票数据
result = await session.call_tool(
"get-stock-data",
arguments={"symbol": "AAPL"}
)
# 获取期权链
options = await session.call_tool(
"get-options-chain",
arguments={
"symbol": "AAPL",
"expiration_date": "2024-12-20"
}
)
if __name__ == "__main__":
import asyncio
asyncio.run(run())