StockFlow MCP Server

StockFlow MCP Server

site icon
2025.02.24 10
Python股票数据期权分析金融分析金融服务
StockFlow MCP Server 是一个基于 Model Context Protocol (MCP) 的服务,提供实时股票数据和期权分析功能。该服务通过 Yahoo Finance 获取市场数据,使 LLMs(大型语言模型)能够访问市场数据、分析股票并评估期权策略。
View on GitHub

Overview

基本能力

产品定位

StockFlow MCP Server 是一个金融数据服务,专注于提供实时股票数据和期权分析,适用于金融分析、投资决策和市场研究。

核心功能

  1. 股票数据
  2. 实时股票价格和关键指标
  3. 包含 OHLC 值的历史价格数据
  4. 公司基本面和财务报表
  5. 市场指标和比率

  6. 期权分析

  7. 完整的期权链数据
  8. Greeks(delta, gamma, theta, vega)
  9. 成交量和未平仓合约跟踪
  10. 期权策略分析

适用场景

  • 实时股票数据查询
  • 历史价格分析
  • 期权策略评估
  • 金融研究和投资决策

工具列表

  1. get-stock-data
  2. 获取当前价格和成交量
  3. 市值和市盈率
  4. 52周高/低点

  5. get-historical-data

  6. OHLC 价格
  7. 可配置的时间周期
  8. 成交量数据

  9. get-options-chain

  10. 看涨和看跌期权
  11. 行权价格
  12. Greeks 和隐含波动率
  13. 成交量和未平仓合约

常见问题解答

  • 数据来源于 Yahoo Finance,可能存在延迟
  • 期权数据的可用性取决于市场交易时间
  • 受 Yahoo Finance API 限制,存在速率限制

使用教程

使用依赖

# 安装依赖
pip install mcp yfinance

安装教程

  1. 克隆仓库:
git clone https://github.com/twolven/mcp-stockflow.git
cd mcp-stockflow
  1. 安装依赖:
pip install -r requirements.txt
  1. 添加到 Claude 配置: 在 claude-desktop-config.jsonmcpServers 部分添加以下内容:
{
    "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())

许可证

该项目遵循 MIT 开源许可条款,请参阅 MIT 了解完整条款。