yfinance
Skill này làm gì
Skill này lấy lịch sử giá và dữ liệu công ty cho cổ phiếu, ETF và chỉ số từ Yahoo Finance. Skill dành cho nhà phân tích và sinh viên cần dữ liệu thị trường miễn phí.
Khi nào nên dùng
- ✓Khi bạn muốn lịch sử giá hằng ngày của một cổ phiếu Mỹ, Hồng Kông hoặc Canada.
- ✓Khi bạn cần thông tin công ty, báo cáo tài chính hoặc chuỗi quyền chọn từ Yahoo Finance.
- ✓Khi bạn muốn dữ liệu thị trường miễn phí cho backtest mà không cần lập tài khoản trả phí.
Liên kết skill
https://github.com/HKUDS/Vibe-Trading/blob/main/agent/src/skills/yfinance/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Lấy năm năm giá hằng ngày của Microsoft và báo cáo tài chính theo quý mới nhất.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Skill dùng dữ liệu Yahoo Finance qua một thư viện bọc Python hoặc một bộ tải có sẵn, và không cần đăng ký. Với dữ liệu giá thông thường, nó đi qua một bộ tải tiêu chuẩn để làm sạch các dòng bị lỗi.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
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_fileresolves 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
.USsuffix → 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-
Câu hỏi thường gặp
Có cần khóa API không?
Không. Dữ liệu Yahoo Finance miễn phí, và skill không cần đăng ký hay khóa.
Skill bao phủ những thị trường nào?
Cổ phiếu, ETF và chỉ số của Mỹ, Hồng Kông và Canada.
Dữ liệu Yahoo có luôn đầy đủ không?
Nguồn miễn phí có thể có khoảng trống hoặc lỗi, nên hãy kiểm tra dữ liệu trước khi dựa vào nó.
Chi tiết
Mô tả gốc của tác giả
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
Độ phổ biến
- Sao GitHub
- 37k
- Vị trí xếp hạng
- #7568
- Giấy phép
- MIT
- Cập nhật
- 1/11/2026
Bình luận
- …
Thêm skill từ kho mã này
vibe-trading
37kCho agent của bạn bộ công cụ nghiên cứu tài chính đầy đủ: backtest, phân tích nhân tố, định giá quyền chọn và dữ liệu thị trường nhiều nước.
adr-hshare
37kChỉ cho agent của bạn cách so sánh giá của một công ty Trung Quốc được niêm yết ở nhiều thị trường, như ADR ở Mỹ và cổ phiếu ở Hồng Kông.
akshare
37kCho agent của bạn lấy dữ liệu thị trường miễn phí: cổ phiếu Trung Quốc và toàn cầu, tương lai, ngoại hối, chỉ số kinh tế, không cần API key.
alpha-zoo
37kCho agent của bạn duyệt thư viện nhân tố cổ phiếu dựng sẵn và kiểm tra cả một nhóm nhân tố dự đoán lợi nhuận tốt đến đâu trên thị trường đã chọn.
Skill tương tự
tavily
394kGiúp agent của bạn tìm kiếm web bằng Tavily và lấy văn bản từ các trang cụ thể, với tùy chọn về độ sâu, tên miền và ngày tháng.
blogwatcher
394kCho phép agent của bạn theo dõi blog và nguồn cấp RSS hoặc Atom, kiểm tra bài viết mới và đánh dấu những bài bạn đã đọc.
data-scraper-agent
280kGiúp agent tự động thu thập dữ liệu từ mọi nguồn công khai. Có thể lên lịch, bổ sung thông tin và lưu kết quả. Hữu ích để theo dõi dữ liệu trực tuyến.