跳到正文
Skillpedia
网页抓取37k · #7568

yfinance

它能做什么

这项技能从 Yahoo Finance 获取股票、ETF 和指数的价格历史与公司数据。适合需要免费行情数据的分析师和学生。

适用场景

  • ✓当你想获取某只美国、香港或加拿大股票的每日价格历史的时候。
  • ✓当你需要从 Yahoo Finance 获取公司信息、财务报表或期权链的时候。
  • ✓当你想在不开设付费账户的情况下,为回测获取免费行情数据的时候。

技能链接

https://github.com/HKUDS/Vibe-Trading/blob/main/agent/src/skills/yfinance/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/HKUDS/Vibe-Trading/blob/main/agent/src/skills/yfinance/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请获取微软过去五年的每日价格,以及最新的季度财务报表。”

每周 5 个新技能,1 分钟读完。

工作原理

它通过 Python 封装库或内置加载器使用 Yahoo Finance 数据,无需注册。对于普通的价格数据,它会通过标准加载器读取,并清理格式错误的行。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

yfinance

Overview

yfinance is an open-source Python wrapper for Yahoo Finance, providing global market data (US, HK, and Canadian stocks, ETFs, indices) including historical and real-time quotes. Completely free, no registration or API key required.

The project has a built-in yfinance DataLoader (backtest/loaders/yfinance_loader.py). When backtesting, set source: "yfinance" or source: "auto" to invoke it automatically.

For OHLCV bars in agent/swarm work, prefer the get_market_data tool when it is available. It routes through the project loader layer, normalizes symbols, removes malformed OHLC rows, and returns strict JSON. Use direct yfinance calls mainly for data outside OHLCV coverage such as company info, financial statements, options, holders, and insider transactions.

Deep Yahoo Interfaces (references/)

Beyond the yfinance package, the project ships a built-in Yahoo public-API client (backtest.loaders.yahoo_client) and two read-only agent tools that sit on top of it. These reach Yahoo's own unauthenticated JSON endpoints directly via requests (no yfinance install needed), share one throttled HTTP gate (Yahoo rate-limits by source IP), and handle the cookie+crumb handshake automatically. Each interface has its own reference doc — read the one you need rather than loading them all:

Doc Covers
yahoo_client.get_chart Direct v8 OHLCV bars (range or epoch window)
yahoo_client.get_quote_summary v10 quoteSummary modules (key stats, financials, ownership)
yahoo_client.get_options v7 option chain (expirations + calls/puts)
yahoo_client.search v1 instrument search by ticker/name
get_options_chain tool Agent tool: US options ladder envelope
get_stock_profile tool Agent tool: company profile/estimates/ownership envelope

Path convention: every link above is written relative to this document (references/...), the form GitHub resolves when the file is opened in a browser. read_file resolves the same string against the skill that owns it, so the agent and a human reader reach one file. Reuse the relative form for any new reference docs, and keep reference paths unique across skills: a path two skills both carry is reported as ambiguous rather than guessed.

The Yahoo client uses the project ticker convention (AAPL.US → AAPL, 00700.HK → 0700.HK, TD.TO and PNG.V pass through); see the Ticker Format Conversion table below — the same rules apply across all of the interfaces above.

Quick Start

Preferred OHLCV tool call:

{
  "codes": ["AAPL.US", "700.HK", "TD.TO", "PNG.V"],
  "start_date": "2025-01-01",
  "end_date": "2026-01-01",
  "source": "yfinance",
  "interval": "1D"
}

If you must write a Python script for OHLCV, use the DataLoader instead of raw yf.download:

from backtest.loaders.registry import get_loader_cls_with_fallback

loader = get_loader_cls_with_fallback("yfinance")()
data = loader.fetch(
    ["AAPL.US", "700.HK", "TD.TO", "PNG.V"],
    "2025-01-01",
    "2026-01-01",
    interval="1D",
)

for symbol, df in data.items():
    print(symbol, df.tail())

Ticker Format Conversion

The project uses a unified ticker format. The DataLoader automatically converts to yfinance format:

Project Format yfinance Format Market
AAPL.US AAPL US stock
MSFT.US MSFT US stock
700.HK 0700.HK HK stock
9988.HK 9988.HK HK stock
TD.TO TD.TO Toronto Stock Exchange stock
PNG.V PNG.V TSX Venture stock
SPY.US SPY US ETF

Rules:

  • US stocks: strip the .US suffix → use the raw ticker
  • HK stocks: keep .HK, pad the number to 4 digits (700 → 0700)
  • Canadian stocks: keep .TO (TSX) or .V (TSXV) unchanged

Supported Data Types

1. Historical OHLCV

Prefer get_market_data for OHLCV whenever the tool is available:

{
  "codes": ["AAPL.US", "MSFT.US", "GOOGL.US"],
  "start_date": "2025-01-01",
  "end_date": "2026-01-01",
  "source": "yfinance",
  "interval": "1D",
  "max_rows": 250
}

For script-

常见问题

需要 API 密钥吗?

不需要。Yahoo Finance 的数据是免费的,技能无需注册或密钥。

它涵盖哪些市场?

涵盖美国、香港和加拿大的股票、ETF 和指数。

Yahoo 的数据总是完整的吗?

免费数据源可能存在缺口或错误,因此在依赖数据之前应进行核对。

详情

作者的原始描述

yfinance global market data interface — retrieve OHLCV and research data for US, HK, and Canadian stocks, ETFs, and indices via Yahoo Finance. Free, no API key required.

repo: HKUDS/Vibe-Trading

热度

GitHub 星标
37k
排名
#7568
许可证
MIT
更新时间
2026/11/1

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能