Y

Yahoo股票筛

@twolven/mcp-stockscreen
3 Stars 1.8k 次浏览 twolven 更新于 2026-08-23

通过Yahoo Finance提供全面的股票筛选功能。使大型语言模型(LLM)能够根据技术、基本面和期权标准筛选股票,并支持观察列表管理和结果存储。

MCP 服务配置

复制以下 JSON 到 OPClaw 或其他 MCP 客户端的配置文件中即可使用

{
  "mcpServers": {
    "stockscreen": {
      "args": [
        "path/to/stockscreen.py"
      ],
      "command": "python"
    }
  }
}

服务介绍

StockScreen MCP 服务器

一个通过 Yahoo Finance 提供全面股票筛选功能的模型上下文协议 (MCP) 服务器。支持基于技术、基本面和期权标准进行股票筛选,并支持观察列表管理和结果存储。

功能

股票筛选

  • 技术分析筛选

    • 价格和成交量过滤器
    • 移动平均线(20、50、200日简单移动平均线)
    • RSI 指标
    • 平均真实波动范围 (ATR)
    • 趋势分析(1天、5天、20天变化)
    • MA 距离计算
  • 基本面筛选

    • 市值过滤器
    • P/E 比率分析
    • 股息收益率标准
    • 收入增长指标
    • ETF 特定指标(资产管理规模、费用比率)
  • 期权筛选

    • 隐含波动率 (IV) 过滤器
    • 期权成交量和未平仓合约
    • 看跌/看涨比率分析
    • 买卖价差评估
    • 盈利日期临近检查

数据管理

  • 观察列表创建和管理
  • 筛选结果存储
  • 默认符号类别
    • 超大市值(>2000亿美元)
    • 大市值(100亿-2000亿美元)
    • 中等市值(20亿-100亿美元)
    • 小市值(3亿-20亿美元)
    • 微市值(<3亿美元)
    • ETF

安装

# Install dependencies
pip install -r requirements.txt

# Clone the repository
git clone https://github.com/twolven/mcp-stockscreen.git
cd mcp-stockscreen

使用

  1. 添加到您的 Claude 配置中:
    在您的 claude-desktop-config.json 文件中,在 mcpServers 部分添加以下内容:
{
    "mcpServers": {
        "stockscreen": {
            "command": "python",
            "args": ["path/to/stockscreen.py"]
        }
    }
}

将 "path/to/stockscreen.py" 替换为您保存 stockscreen.py 文件的完整路径。

可用工具

可用工具

  1. run_stock_screen

技术筛选标准

{
    "screen_type": "technical",
    "criteria": {
        "min_price": float,              # Minimum stock price
        "max_price": float,              # Maximum stock price
        "min_volume": int,               # Minimum average volume
        "above_sma_200": bool,           # Price above 200-day SMA
        "above_sma_50": bool,            # Price above 50-day SMA
        "min_rsi": float,                # Minimum RSI value
        "max_rsi": float,                # Maximum RSI value
        "max_atr_pct": float,            # Maximum ATR as percentage of price
        "category": str                  # Optional: market cap category filter
    },
    "watchlist": str,                    # Optional: name of watchlist to screen
    "save_result": str                   # Optional: name to save results
}

基本面筛选标准

{
    "screen_type": "fundamental",
    "criteria": {
        "min_market_cap": float,         # Minimum market capitalization
        "min_pe": float,                 # Minimum P/E ratio
        "max_pe": float,                 # Maximum P/E ratio
        "min_dividend": float,           # Minimum dividend yield (%)
        "min_revenue_growth": float,     # Minimum revenue growth rate
        "category": str,                 # Optional: market cap category filter
        
        # ETF-specific criteria
        "min_aum": float,                # Minimum assets under management
        "max_expense_ratio": float,      # Maximum expense ratio
        "min_volume": float              # Minimum trading volume
    },
    "watchlist": str,                    # Optional: name of watchlist to screen
    "save_result": str                   # Optional: name to save results
}

期权筛选标准

{
    "screen_type": "options",
    "criteria": {
        "min_iv": float,                 # Minimum implied volatility (%)
        "max_iv": float,                 # Maximum implied volatility (%)
        "min_option_volume": int,        # Minimum options volume
        "min_put_call_ratio": float,     # Minimum put/call ratio
        "max_spread": float,             # Maximum bid-ask spread (%)
        "min_days_to_earnings": int,     # Minimum days until earnings
        "max_days_to_earnings": int,     # Maximum days until earnings
        "category": str                  # Optional: market cap category filter
    },
    "watchlist": str,                    # Optional: name of watchlist to screen
    "save_result": str                   # Optional: name to save results
}

新闻筛选标准

{
    "screen_type": "news",
    "criteria": {
        "keywords": List[str],           # Keywords to search for in news
        "exclude_keywords": List[str],    # Keywords to exclude from results
        "min_days": int,                 # Minimum days back to search
        "max_days": int,                 # Maximum days back to search
        "management_changes": bool,       # Filter for management changes
        "require_all_keywords": bool,     # Require all keywords to match
        "category": str                  # Optional: market cap category filter
    },
    "watchlist": str,                    # Optional: name of watchlist to screen
    "save_result": str                   # Optional: name to save results
}

自定义筛选标准

{
    "screen_type": "custom",
    "criteria": {
        "category": str,                 # Optional: market cap category filter
        "technical": {
            # Any technical criteria from above
        },
        "fundamental": {
            # Any fundamental criteria from above
        },
        "options": {
            # Any options criteria from above
        },
        "news": {
            # Any news criteria from above
        }
    },
    "watchlist": str,                    # Optional: name of watchlist to screen
    "save_result": str                   # Optional: name to save results
}

类别值

可用的市值类别用于过滤:

  • "mega_cap": >2000亿美元
  • "large_cap": 100亿-2000亿美元
  • "mid_cap": 20亿-100亿美元
  • "small_cap": 3亿-20亿美元
  • "micro_cap": <3亿美元
  • "etf": ETF 工具
  1. manage_watchlist
{
    "action": str,                       # Required: "create", "update", "delete", "get"
    "name": str,                         # Required: watchlist name (1-50 chars, alphanumeric with _ -)
    "symbols": List[str]                 # Required for create/update: list of stock symbols
}
  1. get_screening_result
{
    "name": str                          # Required: name of saved screening result
}

响应格式

技术筛选响应

{
    "screen_type": "technical",
    "criteria": dict,                    # Original criteria used
    "matches": int,                      # Number of matching stocks
    "results": [                         # List of matching stocks
        {
            "symbol": str,
            "price": float,
            "volume": float,
            "rsi": float,
            "sma_20": float,
            "sma_50": float,
            "sma_200": float,
            "atr": float,
            "atr_pct": float,
            "price_changes": {
                "1d": float,             # 1-day price change %
                "5d": float,             # 5-day price change %
                "20d": float             # 20-day price change %
            },
            "ma_distances": {
                "pct_from_20sma": float,
                "pct_from_50sma": float,
                "pct_from_200sma": float
            }
        }
    ],
    "rejected": [                        # List of stocks that didn't match
        {
            "symbol": str,
            "rejection_reasons": List[str]
        }
    ],
    "timestamp": str
}

Claude 使用提示

“我已经启用了提供股票筛选功能的 stockscreen 工具。您可以使用三个主要功能:

  1. 用各种标准类型筛选股票:

    • 技术:价格、成交量、RSI、移动平均线、ATR
    • 基本面:市值、P/E、股息、增长率
    • 期权:IV、成交量、盈利日期
    • 自定义:结合多种标准类型
  2. 管理观察列表:

    • 创建和更新符号列表
    • 删除现有观察列表
    • 检索观察列表内容
  3. 访问已保存的筛选结果:

    • 加载之前的筛选结果
    • 查看匹配的符号和标准

所有功能都包括错误处理、详细的市场数据和全面的响应。”

要求

  • Python 3.12+
  • MCP 服务器
  • yfinance
  • pandas
  • numpy
  • asyncio

限制

  • 数据来源于雅虎财经,可能存在延迟
  • 根据雅虎财经API的限制进行速率限制
  • 期权数据的可用性取决于市场时间
  • 某些财务指标可能有延迟或不可用

贡献

欢迎贡献!请随时提交Pull Request。

许可证

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

作者

Todd Wolven - (https://github.com/twolven)

致谢

  • 使用Anthropic的模型上下文协议(MCP)构建
  • 数据由Yahoo Finance提供
  • 为与Anthropic的Claude一起使用而开发

相关 MCP 服务