/ 目錄 / 演練場 / YFinance MCP
● 社群 narumiruna ⚡ 即開即用

YFinance MCP

作者 narumiruna · narumiruna/yfinance-mcp

Yahoo Finance via MCP — quotes, fundamentals, historical OHLC, options chains, news for any ticker, free.

Wraps the yfinance Python package as an MCP. No API key. Good for prototyping finance agents, backtesting ideas, or enriching research prompts with real market data. Data is delayed and rate-limited — not for production trading.

為什麼要用

核心特性

即時演示

實際使用效果

yfinance-mcp.replay ▶ 就緒
0/0

安裝

選擇你的客戶端

~/Library/Application Support/Claude/claude_desktop_config.json  · Windows: %APPDATA%\Claude\claude_desktop_config.json
{
  "mcpServers": {
    "yfinance-mcp": {
      "command": "uvx",
      "args": [
        "yfinance-mcp"
      ]
    }
  }
}

開啟 Claude Desktop → Settings → Developer → Edit Config。儲存後重啟應用。

~/.cursor/mcp.json · .cursor/mcp.json
{
  "mcpServers": {
    "yfinance-mcp": {
      "command": "uvx",
      "args": [
        "yfinance-mcp"
      ]
    }
  }
}

Cursor 使用與 Claude Desktop 相同的 mcpServers 格式。專案級設定優先於全域。

VS Code → Cline → MCP Servers → Edit
{
  "mcpServers": {
    "yfinance-mcp": {
      "command": "uvx",
      "args": [
        "yfinance-mcp"
      ]
    }
  }
}

點擊 Cline 側欄中的 MCP Servers 圖示,然後選 "Edit Configuration"。

~/.codeium/windsurf/mcp_config.json
{
  "mcpServers": {
    "yfinance-mcp": {
      "command": "uvx",
      "args": [
        "yfinance-mcp"
      ]
    }
  }
}

格式與 Claude Desktop 相同。重啟 Windsurf 生效。

~/.continue/config.json
{
  "mcpServers": [
    {
      "name": "yfinance-mcp",
      "command": "uvx",
      "args": [
        "yfinance-mcp"
      ]
    }
  ]
}

Continue 使用伺服器物件陣列,而非映射。

~/.config/zed/settings.json
{
  "context_servers": {
    "yfinance-mcp": {
      "command": {
        "path": "uvx",
        "args": [
          "yfinance-mcp"
        ]
      }
    }
  }
}

加入 context_servers。Zed 儲存後熱重載。

claude mcp add yfinance-mcp -- uvx yfinance-mcp

一行命令搞定。用 claude mcp list 驗證,claude mcp remove 移除。

使用場景

實戰用法: YFinance MCP

Quick snapshot of your watchlist — prices, P/E, news

👤 Investors doing daily check-ins ⏱ ~5 min beginner

何時使用: You want a one-prompt briefing on 10 tickers before market open.

步驟
  1. Prices
    Use yfinance-mcp. For AAPL, MSFT, NVDA, TSLA, GOOGL, AMZN, META, BRK-B, JPM, V — current price, 1d %, 52w range.✓ 已複製
    → Clean table with all 10 rows
  2. Fundamentals
    For the same list, P/E, forward P/E, EPS, and dividend yield.✓ 已複製
    → Fundamentals aligned with prior table
  3. News
    For the 3 biggest movers today, pull the 3 most recent headlines each. Summarize the vibe.✓ 已複製
    → News grouped by ticker with 1-line vibe

結果: A 10-line morning brief tailored to your watchlist.

注意事項
  • Rate-limited if you batch too many tickers at once — Chunk to 10 per call, sleep 1s between
搭配使用: memory

Backtest a simple strategy idea on historical prices

👤 Retail traders prototyping ⏱ ~20 min intermediate

何時使用: You have an idea like "buy SPY when RSI < 30, sell at > 70" and want a quick historical sanity check.

步驟
  1. Pull history
    Pull 5y daily OHLC for SPY.✓ 已複製
    → Time series returned as array
  2. Compute
    Compute RSI(14). Run the "buy<30, sell>70" strategy. Report CAGR, max drawdown, trade count vs buy-and-hold.✓ 已複製
    → Strategy metrics with honest comparison to baseline
  3. Reality check
    Account for commissions ($1/trade) and slippage (5bps). Does the edge survive?✓ 已複製
    → Net-of-costs figures

結果: A go/no-go decision on testing the idea further.

注意事項
  • Survivorship bias — only liquid tickers are in yfinance — For serious backtesting, use a dedicated dataset; yfinance is for sketching
搭配使用: alpaca

組合

與其他 MCP 搭配,撬動十倍槓桿

yfinance-mcp + alpaca

yfinance for research, Alpaca for actual orders

Pick 3 ideas via yfinance, place paper trades via Alpaca.✓ 已複製
yfinance-mcp + memory

Track your own thesis on tickers over time

Store the thesis on NVDA as of today, along with the price.✓ 已複製

工具

此 MCP 暴露的能力

工具輸入參數何時呼叫成本
get_quote ticker: str Current price snapshot free
get_history ticker, period: str, interval: str Historical data for charting or backtest free
get_fundamentals ticker Valuation / fundamentals analysis free
get_options ticker, expiry?: date Option chain lookup free
get_news ticker, limit?: int Ticker-level headlines free

成本與限制

運行它的成本

API 配額
Yahoo's undocumented limits — avoid hammering
每次呼叫 Token 數
OHLC for 5y ≈ 50k tokens, keep requests focused
費用
Free
提示
Resample to weekly for longer histories; only pull daily when you need it

安全

權限、密鑰、影響範圍

憑證儲存: None
資料出站: query1.finance.yahoo.com

故障排查

常見錯誤與修復

Returns empty / error for a ticker

Use Yahoo-format symbols (e.g. BRK-B not BRK.B); some exchanges need suffix (.T for Tokyo)

JSONDecodeError

Yahoo rate-limited you. Back off for a few minutes, or run fewer tickers per batch.

Package out of date

uvx --upgrade yfinance-mcp — Yahoo breaks things regularly

替代方案

YFinance MCP 對比其他方案

替代方案何時用它替代權衡
Alpaca MCPYou want real brokerage data + order placementRequires Alpaca account
Polygon / FinnhubYou need production-grade, low-latency dataPaid; no MCP (yet)

更多

資源

📖 閱讀 GitHub 上的官方 README

🐙 查看未解決的 issue

🔍 瀏覽全部 400+ MCP 伺服器和 Skills