Skip to content
yfinance Data

yfinance Data Skill

A skill for pulling stock and market data with the yfinance Python library: quotes, price history, financial statements, options chains, analyst estimates, holders, news and screens.

GitHub Docs
Data & Analytics
Released
MIT

Install

Install with the skills CLI

One command for Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf and dozens of other agents. Needs Node.js; the skill is fetched straight from himself65/finance-skills.

$ npx skills add himself65/finance-skills --skill yfinance-data

Run it in a terminal. The CLI finds the agents installed on your machine, asks which ones to add the skill to, and whether to install it into the folder you ran it from or for all your projects.

Other ways to install

Copy the whole skill folder — SKILL.md and any scripts or references beside it — into ~/.claude/skills/yfinance-data/, where Claude Code picks it up in every project. Only git is needed.

tmp=$(mktemp -d) && \
  git clone --depth 1 --branch main https://github.com/himself65/finance-skills.git "$tmp" && \
  mkdir -p ~/.claude/skills && \
  cp -R "$tmp"/plugins/market-analysis/skills/yfinance-data ~/.claude/skills/yfinance-data

No scripts or references next to it? Saving the SKILL.md alone as ~/.claude/skills/yfinance-data/SKILL.md works too.

Using another agent? Its personal skills folder
Codex
~/.agents/skills/
Cursor
~/.cursor/skills/
GitHub Copilot
~/.copilot/skills/
Gemini CLI
~/.gemini/skills/
Windsurf
~/.codeium/windsurf/skills/
OpenCode
~/.config/opencode/skills/

About

  • Quotes, OHLCV history and multi-ticker downloads
  • Income statement, balance sheet and cash flow, annual or quarterly
  • Options chains, dividends and splits
  • Analyst targets, ratings, earnings and estimates
  • Institutional and insider holdings, news
  • Stock screens and sector/industry data

yfinance Data is a skill from Alex Yang's finance-skills collection that gives an agent a reliable way to answer stock and market questions with the open-source yfinance library, which reads Yahoo Finance. It is designed to trigger even when the user types only a ticker such as AAPL and the intent has to be inferred.

The skill first checks whether yfinance is installed and installs it with pip if not. It then maps the request to a data category through a lookup table: current quotes and OHLCV history, income statements, balance sheets and cash flow (annual or quarterly), dividends and splits, options chains (listing expiries first), earnings history, analyst price targets, recommendations and rating changes, institutional holders and insider transactions, news, multi-ticker comparisons with yf.download, stock screens with yf.EquityQuery, and sector and industry data. A bundled API reference holds the code for each.

Its rules cover the usual traps: wrapping calls against rate limits and empty data, intraday history limits (about 7 days for 1-minute bars and 730 for hourly), and timezone-aware indexes. Results are presented answer first, with a trimmed table and notable context such as an earnings beat or unusual volume. It notes that yfinance is not affiliated with Yahoo and its data is for research and education. For earnings previews, valuation, correlation and similar analyses, the collection has dedicated skills. MIT-licensed.

SKILL.md

The instructions your agent loads, as published by Alex Yang (himself65).

SKILL.md
name
yfinance-data
description
Fetch financial and market data with the yfinance Python library (Yahoo Finance). Use this skill whenever the user wants stock data: current quotes and price history, financial statements (income statement, balance sheet, cash flow), options chains, dividends and splits, earnings and analyst estimates, price targets and ratings, institutional and insider holdings, news, multi-ticker comparisons, stock screens, or sector and industry data. Use it even when the user gives only a ticker symbol (AAPL, MSFT, TSLA) and the intent has to be inferred. For earnings previews or recaps, estimate revisions, valuation, correlation, liquidity, or ETF premium analysis, prefer the dedicated skill.

yfinance Data Skill

If your host has not already executed the shell probes below (for example, in Codex), run the commands inside the ! wrappers with its shell tool before choosing a setup path. Use the actual output; if shell access is unavailable, report that limitation.

Fetches financial and market data from Yahoo Finance using the yfinance Python library.

Important: yfinance is not affiliated with Yahoo, Inc. Data is for research and educational purposes.

---

Step 1: Ensure yfinance Is Available

Current environment status:

!`python3 -c "exec('try:\n import yfinance\n print(\'yfinance \' + yfinance.__version__ + \' installed\')\nexcept Exception:\n print(\'YFINANCE_NOT_INSTALLED\')')"`

If YFINANCE_NOT_INSTALLED, install it before running any code:

import subprocess, sys
subprocess.check_call([sys.executable, "-m", "pip", "install", "-q", "yfinance"])

If yfinance is already installed, skip the install step and proceed directly.

---

Step 2: Identify What the User Needs

Match the user's request to one or more data categories below, then use the corresponding code from references/api_reference.md.

User RequestData CategoryPrimary Method
Stock price, quoteCurrent priceticker.info or ticker.fast_info
Price history, chart dataHistorical OHLCVticker.history() or yf.download()
Balance sheetFinancial statementsticker.balance_sheet
Income statement, revenueFinancial statementsticker.income_stmt
Cash flowFinancial statementsticker.cashflow
DividendsCorporate actionsticker.dividends
Stock splitsCorporate actionsticker.splits
Options chain, calls, putsOptions dataticker.option_chain()
Earnings, EPSAnalysisticker.earnings_history
Analyst price targetsAnalysisticker.analyst_price_targets
Recommendations, ratingsAnalysisticker.recommendations
Upgrades/downgradesAnalysisticker.upgrades_downgrades
Institutional holdersOwnershipticker.institutional_holders
Insider transactionsOwnershipticker.insider_transactions
Company overview, sectorGeneral infoticker.info
Compare multiple stocksBulk downloadyf.download()
Screen/filter stocksScreeneryf.screen() + yf.EquityQuery
Sector/industry dataMarket datayf.Sector / yf.Industry
NewsNewsticker.news

---

Step 3: Write and Execute the Code
General pattern
import yfinance as yf

ticker = yf.Ticker("AAPL")
# ... use the appropriate method from the reference
Key rules
  1. Always wrap in try/except — Yahoo Finance may rate-limit or return empty data
  2. Use `yf.download()` for multi-ticker comparisons — it's faster with multi-threading
  3. For options, list expiration dates first with ticker.options before calling ticker.option_chain(date)
  4. For quarterly data, use quarterly_ prefix: ticker.quarterly_income_stmt, ticker.quarterly_balance_sheet, ticker.quarterly_cashflow
  5. For large date ranges, be mindful of intraday limits — 1m data only goes back ~7 days, 1h data ~730 days
  6. Print DataFrames clearly — use .to_string() or .to_markdown() for readability, or select key columns
  7. Timezone handling — yfinance returns tz-aware datetime indices (e.g., America/New_York). When comparing dates, always use pd.Timestamp(..., tz=...) or strip timezones with .tz_localize(None). See the reference file for details.
Valid periods and intervals
Periods1d, 5d, 1mo, 3mo, 6mo, 1y, 2y, 5y, 10y, ytd, max
Intervals1m, 2m, 5m, 15m, 30m, 60m, 90m, 1h, 1d, 5d, 1wk, 1mo, 3mo

---

Step 4: Present the Data

Answer with the numbers the user asked for first, then the supporting table (markdown, or a trimmed DataFrame with the key columns). Call out anything notable in the data — an earnings beat or miss, unusual volume, a dividend change — and add context such as sector averages, historical ranges, or analyst consensus where it changes how the numbers read. If the user wants a chart, pair the data with a visualization.

---

Reference Files
  • references/api_reference.md — Complete yfinance API reference with code examples for every data category

Read the reference file when you need exact method signatures or edge case handling.

Install

Skill: Meme Rush

by Binance

New

Binance's official skill for live meme-token launchpad feeds on Solana, BNB Chain and Base (new, finalizing and migrated tokens on Pump.fun, Four.meme and more) plus AI-detected hot market narratives.

Coinbase's official skill for driving a crypto wallet from an agent: balances and transfers on Base, Polygon and Solana, plus paying for and monetising x402 APIs.

Skill: Geo OSINT Locator

by Enrico Frumento

Forensic single-image geolocation: builds competing place hypotheses, verifies them across independent evidence, falsifies the runner-up and only names an exact spot after a strict gate.

Browse all skills →