Skip to main content
Glama

YFinance Trader MCP Tool

适用于 Claude 桌面的 YFinance Trader MCP 工具

一种 MCP(模型上下文协议)工具,使用 yfinance 库提供股票市场数据和交易功能,专门针对 Claude Desktop 进行调整。

图片来源:本项目灵感源自 Luigi Ajah 的mcp-stocks ,后者是 Cursor 的一个类似实现。本次改编修改了原始概念,使其能够与 Claude Desktop 兼容。

教程

有关设置和使用此工具的详细指南,请查看我们的 Medium 教程: 教程:使用 Claude Desktop 和 YFinance Trader MCP 工具访问实时股票市场数据

特征

  • 实时股票报价
  • 公司信息和财务指标
  • 历史价格数据
  • 符号搜索功能
  • 分析师建议
  • 内幕交易追踪

设置

  1. 确保安装了 Python 3.10 或更高版本
  2. 安装依赖项:
pip install -r requirements.txt

与 Claude Desktop 集成

  1. 通过将以下内容添加到您的 MCP 配置中,在 Claude Desktop 中配置您的 MCP 设置:
{ "mcpServers": { "yfinance-trader": { "command": "py", "args": ["-3.13", "path/to/your/main.py"] } } }
  1. 将路径替换为 main.py 文件的完整路径
  2. 如果需要,重新启动 Claude Desktop

可用工具

1. 获取股票报价

获取实时股票报价信息:

{ "symbol": "AAPL", "price": 150.25, "change": 2.5, "changePercent": 1.67, "volume": 1234567, "timestamp": "2024-03-20T10:30:00" }

2. 获取公司概览

获取公司信息和关键指标:

{ "name": "Apple Inc.", "sector": "Technology", "industry": "Consumer Electronics", "marketCap": 2500000000000, "peRatio": 25.4, "forwardPE": 24.2, "dividendYield": 0.65, "52WeekHigh": 182.94, "52WeekLow": 124.17 }

3. 获取每日时间序列

获取历史每日价格数据:

{ "symbol": "AAPL", "timeSeriesDaily": [ { "date": "2024-03-20T00:00:00", "open": 150.25, "high": 152.30, "low": 149.80, "close": 151.75, "volume": 12345678 } // ... more data points ] }

4. 搜索符号

搜索股票和其他证券:

{ "results": [ { "symbol": "AAPL", "name": "Apple Inc.", "type": "EQUITY", "exchange": "NASDAQ" } // ... more results ] }

5. 获取建议

获取股票分析师的建议:

{ "symbol": "AAPL", "recommendations": [ { "period": "2024-03-15T00:00:00", "strongBuy": 15, "buy": 20, "hold": 8, "sell": 2, "strongSell": 0 } // ... more periods ] }

6. 获取内部交易

获取内幕交易信息:

{ "symbol": "AAPL", "transactions": [ { "date": "2024-03-15T00:00:00", "insider": "John Doe", "position": "Director", "transactionType": "Buy", "shares": 1000, "value": 150250.00, "url": "https://finance.yahoo.com/...", "text": "Purchase of 1000 shares", "startDate": "2024-03-15", "ownership": "Direct" } // ... more transactions ] }

示例查询

您可以向 Claude Desktop 询问以下问题:

  • “AAPL 的当前股价和每日变化是多少?”
  • “您能给我介绍一下微软(MSFT)的公司概况吗?”
  • “显示过去 3 个月特斯拉 (TSLA) 的历史价格数据。”
  • “搜索与‘NVDA’相关的股票。”
  • “分析师对亚马逊(AMZN)的建议是什么?”
  • “谷歌(GOOGL)最近有内幕交易吗?”

加密货币支持

有限的加密货币数据可通过特殊的股票代码格式获得:

  • BTC-USD 比特币
  • ETH-USD 代表以太坊
  • DOGE-USD 为狗狗币

错误处理

所有工具都包含适当的错误处理,如果出现问题,将返回错误消息:

{ "error": "Failed to fetch quote for INVALID_SYMBOL" }

故障排除

如果 MCP 服务器在 Claude Desktop 中无法运行:

  1. 确保服务器正在运行 - 启动脚本时您应该看到输出
  2. 验证设置中的路径是否正确且绝对
  3. 确保 Python 3.10+ 位于你的系统 PATH 中
  4. 检查所有依赖项是否已安装
  5. 尝试重启 Claude Desktop
  6. 检查日志中是否有任何错误消息

与原始 mcp-stocks 项目的区别

  • 直接使用 MCP 库,而不是 FastAPI
  • 适用于 Claude Desktop 而非 Cursor
  • 修改错误处理和响应格式
  • 更新的配置方法

执照

MIT 许可证

-
security - not tested
A
license - permissive license
-
quality - not tested

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

使用 yfinance 库提供股票市场数据和交易功能

  1. 教程
    1. 特征
      1. 设置
        1. 与 Claude Desktop 集成
          1. 可用工具
            1. 获取股票报价
            2. 获取公司概览
            3. 获取每日时间序列
            4. 搜索符号
            5. 获取建议
            6. 获取内部交易
          2. 示例查询
            1. 加密货币支持
              1. 错误处理
                1. 故障排除
                  1. 与原始 mcp-stocks 项目的区别
                    1. 执照

                      Related MCP Servers

                      • -
                        security
                        F
                        license
                        -
                        quality
                        A TypeScript-based MCP server that fetches real-time stock market data and company financial information through the Alpha Vantage API.
                        Last updated -
                        JavaScript
                        • Apple
                      • A
                        security
                        A
                        license
                        A
                        quality
                        A simple MCP server for Yahoo Finance using yfinance. This server provides a set of tools to fetch stock data, news, and other financial information.
                        Last updated -
                        10
                        20
                        Python
                        MIT License
                      • -
                        security
                        F
                        license
                        -
                        quality
                        Provides real-time access to global stock market data including current prices, historical charts, and company financial information through a Model Context Protocol (MCP) server for AI assistants.
                        Last updated -
                        TypeScript
                        • Linux
                        • Apple
                      • A
                        security
                        A
                        license
                        A
                        quality
                        A Model Context Protocol server that enables interaction with Yahoo Finance to retrieve stock pricing, company information, and historical financial data through natural language queries.
                        Last updated -
                        9
                        2
                        Python
                        MIT License

                      View all related MCP servers

                      MCP directory API

                      We provide all the information about MCP servers via our MCP API.

                      curl -X GET 'https://glama.ai/api/mcp/v1/servers/SaintDoresh/YFinance-Trader-MCP-ClaudeDesktop'

                      If you have feedback or need assistance with the MCP directory API, please join our Discord server