Agent skill

yfinance Market Data

by HKUDS in HKUDS/Vibe-Trading

Pulls price history and company research data for US, Hong Kong and Canadian stocks, ETFs and indices from Yahoo Finance, with no API key.

MITAuto-check passedBusiness, Finance & HR

Install yfinance Market Data

skills CLI
$ npx skills add HKUDS/Vibe-Trading --skill yfinance -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install HKUDS/Vibe-Trading yfinance --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/HKUDS/Vibe-Trading.git skills-src && mkdir -p .claude/skills && cp -r skills-src/agent/src/skills/yfinance .claude/skills/yfinance && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
yfinance
GitHub stars
35k
Token cost
~2.2k tokens
SKILL.md length
676 words
Files
7 (incl. references)
Skills in repo
89
Repo updated
First seen
Licence
MIT

At a glance

Pulls price history and company research data for US, Hong Kong and Canadian stocks, ETFs and indices from Yahoo Finance, with no API key.

  • Works in 7 steps: Historical OHLCV → Company Info → Financial Statements → …
  • Downloading daily price bars for a US or Canadian ticker
  • SKILL.md covers Overview, Deep Yahoo Interfaces…, Quick Start and Ticker Format Conversion, plus 3 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

This skill explains how to get market data through yfinance, the open-source Python wrapper for Yahoo Finance. Beyond OHLCV bars it reaches company info, financial statements, options, holders and insider transactions, and it needs no registration or API key.

Inside the Vibe-Trading project a built-in yfinance loader switches on when a backtest sets its data source to yfinance or auto. For plain price bars the skill prefers the get_market_data tool, which normalizes symbols and drops malformed rows, and saves direct yfinance calls for the other data types. Six reference documents describe the project's own Yahoo client (chart, quote summary, options, search) and the get_options_chain and get_stock_profile tools. The agent is told to open only the one it needs, and calls share one throttled gate because Yahoo limits by source IP.

When your agent uses it

  • Downloading daily price bars for a US or Canadian ticker
  • Looking up financial statements or insider transactions for a company
  • Pulling an options chain for a US stock
  • Choosing a free data source for a backtest

Example prompts

  • “Get the last year of daily bars for SPY and summarize the trend.”
  • “Show the income statement and major holders for Shopify's Toronto listing.”
  • “Pull the nearest-expiry option chain for AAPL and list the calls near the money.”
  • “Run my backtest with the yfinance source instead of auto.”

Requirements

  • Python with the yfinance package, or the project's built-in Yahoo client
  • Network access to Yahoo Finance

Workflow steps

7 steps, taken from the step headings in SKILL.md.

  1. Historical OHLCV
  2. Company Info
  3. Financial Statements
  4. Dividends and Splits
  5. Institutional Holdings
  6. Indices and ETFs
  7. FX Rates

What it can do on your machine

Read from SKILL.md and the folder at commit e532650. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are python and json).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

yfinance Market Data loads about 2.2k tokens when it runs, and up to ~6.5k if it reads all its reference files. Until then it costs about 45 tokens; SKILL.md has 676 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~45
When it runs · the whole SKILL.md, loaded when a task matches
~2.2k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~6.5k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from HKUDS/Vibe-Trading at commit e532650, republished under its MIT licence (© HKUDS). 676 words, ~2,247 tokens.

Download SKILL.mdSave it as .claude/skills/yfinance/SKILL.md (or your agent's skills folder). This skill also uses 6 other files; get the full folder from GitHub.
name
yfinance
description
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.
category
data-source

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:

DocCovers
yahoo_client.get_chartDirect v8 OHLCV bars (range or epoch window)
yahoo_client.get_quote_summaryv10 quoteSummary modules (key stats, financials, ownership)
yahoo_client.get_optionsv7 option chain (expirations + calls/puts)
yahoo_client.searchv1 instrument search by ticker/name
get_options_chain toolAgent tool: US options ladder envelope
get_stock_profile toolAgent 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:

json
{
  "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:

python
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 Formatyfinance FormatMarket
AAPL.USAAPLUS stock
MSFT.USMSFTUS stock
700.HK0700.HKHK stock
9988.HK9988.HKHK stock
TD.TOTD.TOToronto Stock Exchange stock
PNG.VPNG.VTSX Venture stock
SPY.USSPYUS 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
Show full SKILL.md (233 more words)Show less

Supported Data Types

1. Historical OHLCV

Prefer get_market_data for OHLCV whenever the tool is available:

json
{
  "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-based OHLCV analysis, use the loader:

python
from backtest.loaders.registry import get_loader_cls_with_fallback

loader = get_loader_cls_with_fallback("yfinance")()

# Single stock
single = loader.fetch(["AAPL.US"], "2025-01-01", "2026-01-01", interval="1D")

# Specific interval
hourly = loader.fetch(["AAPL.US"], "2026-03-01", "2026-03-30", interval="1H")

Supported intervals:

  • Minute-level: 1m, 2m, 5m, 15m, 30m, 60m, 90m
  • Hourly: 1h
  • Daily and above: 1d, 5d, 1wk, 1mo, 3mo

Minute data limits:

  • 1m: up to 7 days of history
  • 2m/5m/15m/30m/60m/90m: up to 60 days
  • 1h: up to 730 days
  • 1d and above: unlimited
2. Company Info
python
ticker = yf.Ticker("AAPL")

info = ticker.info
print(f"Company: {info.get('longName')}")
print(f"Industry: {info.get('industry')}")
print(f"Market cap: {info.get('marketCap')}")
print(f"PE: {info.get('trailingPE')}")
print(f"EPS: {info.get('trailingEps')}")
print(f"Dividend yield: {info.get('dividendYield')}")
3. Financial Statements
python
ticker = yf.Ticker("AAPL")

# Income statement (annual)
income = ticker.financials
# Income statement (quarterly)
income_q = ticker.quarterly_financials

# Balance sheet
balance = ticker.balance_sheet

# Cash flow statement
cashflow = ticker.cashflow

# Earnings data
earnings = ticker.earnings
4. Dividends and Splits
python
ticker = yf.Ticker("AAPL")

# Dividend history
dividends = ticker.dividends

# Stock split history
splits = ticker.splits

# All corporate actions
actions = ticker.actions
5. Institutional Holdings
python
ticker = yf.Ticker("AAPL")

# Institutional holders
holders = ticker.institutional_holders

# Major holders summary
major = ticker.major_holders

# Insider transactions
insider = ticker.insider_transactions
6. Indices and ETFs
python
# Major indices
sp500 = yf.download("^GSPC", start="2025-01-01", end="2026-01-01", progress=False)  # S&P 500
nasdaq = yf.download("^IXIC", start="2025-01-01", end="2026-01-01", progress=False)  # NASDAQ
hsi = yf.download("^HSI", start="2025-01-01", end="2026-01-01", progress=False)      # Hang Seng Index

# ETFs
spy = yf.download("SPY", start="2025-01-01", end="2026-01-01", progress=False)
qqq = yf.download("QQQ", start="2025-01-01", end="2026-01-01", progress=False)
7. FX Rates
python
# Currency pairs
usdcny = yf.download("CNY=X", start="2025-01-01", end="2026-01-01", progress=False)
usdhkd = yf.download("HKD=X", start="2025-01-01", end="2026-01-01", progress=False)
eurusd = yf.download("EURUSD=X", start="2025-01-01", end="2026-01-01", progress=False)

Backtest Usage

config.json Example
json
{
  "source": "yfinance",
  "codes": ["AAPL.US", "MSFT.US"],
  "start_date": "2020-01-01",
  "end_date": "2026-03-30",
  "initial_cash": 1000000,
  "commission": 0.001,
  "extra_fields": null
}
Cross-Market Auto Mode
json
{
  "source": "auto",
  "codes": ["000001.SZ", "AAPL.US", "700.HK", "BTC-USDT"],
  "start_date": "2024-01-01",
  "end_date": "2026-03-30",
  "initial_cash": 1000000,
  "commission": 0.001,
  "extra_fields": null
}

source: "auto" routes automatically by ticker format: A-shares → the China fallback chain, HK stocks → the HK chain, Canadian .TO/.V stocks → Yahoo/yfinance, and crypto → OKX.

Notes

  • Free, no API key: yfinance scrapes Yahoo Finance public data — no registration needed
  • Rate limits: high-frequency requests may trigger temporary Yahoo bans — prefer batch downloads over per-ticker loops
  • Minute data range: limited by Yahoo Finance (see table above)
  • HK tickers: Yahoo Finance uses 4-digit numbers + .HK; pad with leading zeros where needed
  • Adjustment: auto_adjust=True (default) returns forward-adjusted prices; the project loader uses auto_adjust=False
  • Timezone: returned data includes timezone info; the DataLoader strips it automatically
  • extra_fields not supported: yfinance via the backtest loader returns OHLCV only; PE/PB and other fundamentals require separate yf.Ticker().info calls
  • Comparison with Tushare: Tushare covers deep A-share data (financials, fund flows, block trades, etc.); yfinance covers global markets but with less depth

© HKUDS, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 6 other files (references) in agent/src/skills/yfinance of HKUDS/Vibe-Trading.

  • SKILL.md
  • references/tool_get_options_chain.md
  • references/tool_get_stock_profile.md
  • references/yahoo_client_get_chart.md
  • references/yahoo_client_get_options.md
  • references/yahoo_client_get_quote_summary.md
  • references/yahoo_client_search.md

Open the folder on GitHubat commit e532650

Compare with similar skills

yfinance Market Data next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

yfinance Market Data compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
yfinance Market Data this skillHKUDS/Vibe-Trading35k—~2.2kAutomated safety check: PassMIT
WorldQuant BRAIN Alpha ResearchQuantML-Research/wq-alpha-research405—~4.9kAutomated safety check: PassNone
Regimejackson-video-resources/markov-hedge-fund-method483—~1.6kAutomated safety check: PassCustom licence
Tushare Datazillionare/zillionare3212 repos~2.3kAutomated safety check: PassNone
Polymarket Tennislivetennisapi/livetennisapi-mcp152—~3kAutomated safety check: PassMIT
Yahoo Finance24mlight/StockClaw1012 repos~1.1kAutomated safety check: NotesMIT

Similar skills

  • WorldQuant BRAIN Alpha Research

    QuantML-Research/wq-alpha-research

    Chinese-language playbook for WorldQuant BRAIN alphas: choose fields, write expressions, backtest, diagnose check failures, tune turnover, submit and build portfolios.

    405 GitHub stars~4.9k tokensUpdated 3 mo ago
    Business, Finance & HRAuto-check passed
  • Regime

    jackson-video-resources/markov-hedge-fund-method

    Detect the market regime (Bull / Bear / Sideways) for ANY asset and turn it into a tradeable signal or a risk filter.

    483 GitHub stars~1.6k tokensUpdated 4 mo ago
    Business, Finance & HRAuto-check passed
  • Tushare Data

    zillionare/zillionare

    面向中文自然语言的 Tushare 数据研究技能。用于把“看看这只股票最近怎么样”“帮我查财报趋势”“最近哪个板块最强”“北向资金在买什么”“给我导出一份行情数据”这类请求,转成可执行的数据获取、清洗、对比、筛选、导出与简要分析流程。适用于 A 股、指数、ETF/基金、财务、估值、资金流、公告新闻、板块概念与宏观数据等研究场景。

    321 GitHub starsUsed in 2 repos~2.3k tokens
    Business, Finance & HRAuto-check passed
  • Polymarket Tennis

    livetennisapi/livetennisapi-mcp

    Build observe-only Polymarket and Kalshi tennis market tooling on the polymarket-tennis Python package (MIT) plus the Live Tennis API free tier.

    152 GitHub stars~3k tokensUpdated 2 days ago
    Business, Finance & HRAuto-check passed
  • Yahoo Finance

    24mlight/StockClaw

    Get stock prices, quotes, fundamentals, earnings, options, dividends, and analyst ratings using Yahoo Finance.

    101 GitHub starsUsed in 2 repos~1.1k tokens
    Business, Finance & HRAuto-check: notes
  • Stock Analysis

    liusai0820/Stock-Analysis-Skill

    股票智能分析技能。输入股票代码(A股/港股/美股),自动完成: 1. An agent skill from liusai0820/Stock-Analysis-Skill.

    141 GitHub stars~904 tokensUpdated 7 mo ago
    Business, Finance & HRAuto-check: notes

More from HKUDS/Vibe-Trading

All 89 skills in this repo
  • Eastmoney Market Data

    HKUDS/Vibe-Trading

    Index of Eastmoney's free, no-token market data interfaces for China A-shares and Hong Kong stocks: fund flows, dragon-tiger lists, margin trading, reports and news.

    35k GitHub stars~1k tokensUpdated today
    Auto-check passed
  • OKX Market Data

    HKUDS/Vibe-Trading

    Retrieves public OKX cryptocurrency market data such as spot prices, candlesticks, funding rates and open interest through the OKX V5 REST API, with no authentication.

    35k GitHub stars~1.3k tokensUpdated today
    Auto-check passed
  • SEC EDGAR Filings Fetcher

    HKUDS/Vibe-Trading

    Fetches U.S. SEC EDGAR data: resolves tickers to CIK numbers, lists recent 10-K, 10-Q and 8-K filings with document URLs, and pulls XBRL financial series.

    35k GitHub stars~1.4k tokensUpdated today
    Auto-check passed
  • A-Share ST Risk Screener

    HKUDS/Vibe-Trading

    Predicts whether a mainland China A-share company risks an ST or *ST warning after its next annual report, using financial thresholds and Sina penalty records.

    35k GitHub stars~4.9k tokensUpdated today
    Auto-check passed
  • Breaks a structural trend such as AI infrastructure into its physical supply chain and ranks lesser-known listed companies sitting on each bottleneck.

    35k GitHub stars~2.7k tokensUpdated today
    Auto-check passed
  • Plans and drafts an eight-part, roughly 120k-word investigative series on one company, built around a strict fact-check pass rather than fast drafting.

    35k GitHub stars~2.4k tokensUpdated today
    Auto-check passed

Works with

Questions about yfinance Market Data

What does yfinance Market Data do?

Pulls price history and company research data for US, Hong Kong and Canadian stocks, ETFs and indices from Yahoo Finance, with no API key. This skill explains how to get market data through yfinance, the open-source Python wrapper for Yahoo Finance. Beyond OHLCV bars it reaches company info, financial statements, options, holders and insider transactions, and it needs no registration or API key.

When should I use yfinance Market Data?

yfinance Market Data fits situations like: downloading daily price bars for a US or Canadian ticker; looking up financial statements or insider transactions for a company; pulling an options chain for a US stock; choosing a free data source for a backtest.

How do I install yfinance Market Data in Claude Code?

Run `npx skills add HKUDS/Vibe-Trading --skill yfinance -a claude-code`. Or copy the skill folder (agent/src/skills/yfinance in HKUDS/Vibe-Trading) into .claude/skills/yfinance in your project. Claude Code loads it when a task matches its description.

How do I install yfinance Market Data in Codex?

Run `npx skills add HKUDS/Vibe-Trading --skill yfinance -a codex`. Or copy the skill folder (agent/src/skills/yfinance in HKUDS/Vibe-Trading) into .agents/skills/yfinance in your project. Codex loads it when a task matches its description.

Can I use yfinance Market Data in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add HKUDS/Vibe-Trading --skill yfinance -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/yfinance, .gemini/skills/yfinance, .github/skills/yfinance and .opencode/skills/yfinance in your project.

What does yfinance Market Data need to run?

SKILL.md names no scripts, command-line tools or credentials: yfinance Market Data is instructions for the agent only. Our summary lists: Python with the yfinance package, or the project's built-in Yahoo client; Network access to Yahoo Finance.

Does yfinance Market Data access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is yfinance Market Data safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does yfinance Market Data use?

yfinance Market Data is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does yfinance Market Data use?

About 2.2k tokens (SKILL.md is roughly 9k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 4.3k tokens, read only when the agent opens those files.

What are the alternatives to yfinance Market Data?

Skills that share tags, products or a category with yfinance Market Data: WorldQuant BRAIN Alpha Research (QuantML-Research/wq-alpha-research, 405 stars), Regime (jackson-video-resources/markov-hedge-fund-method, 483 stars), Tushare Data (zillionare/zillionare, 321 stars) and Polymarket Tennis (livetennisapi/livetennisapi-mcp, 152 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains yfinance Market Data?

HKUDS (a GitHub organization) maintains it in HKUDS/Vibe-Trading, which has 35,043 GitHub stars. The repository holds 89 skills in this directory. The repository was last updated on October 8, 2026.

Source: HKUDS/Vibe-Trading on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.