yfinance Data Skill

Fetch financial and market data using the yfinance Python library.

How to use it

Claude Code
  1. Run the line below. It pulls the whole folder into ~/.claude/skills/yfinance-data.
  2. Describe your job in plain words. Claude Code follows the skill from there.
Claude Code — installs the whole folder, not just SKILL.md
npx degit himself65/finance-skills/plugins/market-analysis/skills/yfinance-data#main ~/.claude/skills/yfinance-data

For one project only, change the path to .claude/skills/yfinance-data.

Claude (web or desktop app)
  1. On this page open ⋯ → Download .md.
  2. Save it as SKILL.md in a folder, zip the folder, then Customize → Skills → + → Create skill → Upload a skill.
  3. Pick the file and Save. Claude shows the name and description and runs a security scan.
  4. Check the skill is switched on.
  5. Start a new chat and describe your job in plain words. The AI follows the skill from there.
ChatGPT or another app
  1. ChatGPT: make a Project and paste it into Instructions.
  2. Neither? Paste it at the top of a new chat — it works for that chat.
Not working?
  • Check which app you pasted it into — the steps above name the right one.
  • Some skills need the paid tier of Claude or ChatGPT.
Step-by-step guide with screenshots · Ask in the forum

Paste into Claude, ChatGPT or Cursor.

Source of yfinance Data Skill

Show the full text120 lines
namedescription
yfinance-data> Fetch financial and market data using the yfinance Python library. Use this skill whenever the user asks for stock prices, historical data, financial statements, options chains, dividends, earnings, analyst recommendations, or any market data. Triggers include: any mention of stock price, ticker symbol (AAPL, MSFT, TSLA, etc.), get me the financials", "show earnings", "what's the price of", "download stock data", options chain", "dividend history", "balance sheet", "income statement", "cash flow", analyst targets", "institutional holders", "compare stocks", "screen for stocks", or any request involving Yahoo Finance data. Always use this skill even if the user only provides a ticker — infer intent from context.

yfinance Data Skill

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 Request Data Category Primary Method
Stock price, quote Current price ticker.info or ticker.fast_info
Price history, chart data Historical OHLCV ticker.history() or yf.download()
Balance sheet Financial statements ticker.balance_sheet
Income statement, revenue Financial statements ticker.income_stmt
Cash flow Financial statements ticker.cashflow
Dividends Corporate actions ticker.dividends
Stock splits Corporate actions ticker.splits
Options chain, calls, puts Options data ticker.option_chain()
Earnings, EPS Analysis ticker.earnings_history
Analyst price targets Analysis ticker.analyst_price_targets
Recommendations, ratings Analysis ticker.recommendations
Upgrades/downgrades Analysis ticker.upgrades_downgrades
Institutional holders Ownership ticker.institutional_holders
Insider transactions Ownership ticker.insider_transactions
Company overview, sector General info ticker.info
Compare multiple stocks Bulk download yf.download()
Screen/filter stocks Screener yf.Screener + yf.EquityQuery
Sector/industry data Market data yf.Sector / yf.Industry
News News ticker.news

Step 3: Write and Execute the Code

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

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
Periods 1d, 5d, 1mo, 3mo, 6mo, 1y, 2y, 5y, 10y, ytd, max
Intervals 1m, 2m, 5m, 15m, 30m, 60m, 90m, 1h, 1d, 5d, 1wk, 1mo, 3mo

Step 4: Present the Data

After fetching data, present it clearly:

  1. Summarize key numbers in a brief text response (current price, market cap, P/E, etc.)
  2. Show tabular data formatted for readability — use markdown tables or formatted DataFrames
  3. Highlight notable items — earnings beats/misses, unusual volume, dividend changes
  4. Provide context — compare to sector averages, historical ranges, or analyst consensus when relevant

If the user seems to want a chart or visualization, combine with an appropriate visualization approach (e.g., generate an HTML chart or describe the trend).


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.

1---
2name: yfinance-data
3description: >
4 Fetch financial and market data using the yfinance Python library.
5 Use this skill whenever the user asks for stock prices, historical data, financial statements,
6 options chains, dividends, earnings, analyst recommendations, or any market data.
7 Triggers include: any mention of stock price, ticker symbol (AAPL, MSFT, TSLA, etc.),
8 "get me the financials", "show earnings", "what's the price of", "download stock data",
9 "options chain", "dividend history", "balance sheet", "income statement", "cash flow",
10 "analyst targets", "institutional holders", "compare stocks", "screen for stocks",
11 or any request involving Yahoo Finance data.
12 Always use this skill even if the user only provides a ticker — infer intent from context.
13---
14 
15# yfinance Data Skill
16 
17Fetches financial and market data from Yahoo Finance using the [yfinance](https://github.com/ranaroussi/yfinance) Python library.
18 
19**Important**: yfinance is not affiliated with Yahoo, Inc. Data is for research and educational purposes.
20 
21---
22 
23## Step 1: Ensure yfinance Is Available
24 
25**Current environment status:**
26 
27```
28!`python3 -c "exec('try:\n import yfinance\n print(\'yfinance \' + yfinance.__version__ + \' installed\')\nexcept Exception:\n print(\'YFINANCE_NOT_INSTALLED\')')"`
29```
30 
31If `YFINANCE_NOT_INSTALLED`, install it before running any code:
32 
33```python
34import subprocess, sys
35subprocess.check_call([sys.executable, "-m", "pip", "install", "-q", "yfinance"])
36```
37 
38If yfinance is already installed, skip the install step and proceed directly.
39 
40---
41 
42## Step 2: Identify What the User Needs
43 
44Match the user's request to one or more data categories below, then use the corresponding code from `references/api_reference.md`.
45 
46| User Request | Data Category | Primary Method |
47|---|---|---|
48| Stock price, quote | Current price | `ticker.info` or `ticker.fast_info` |
49| Price history, chart data | Historical OHLCV | `ticker.history()` or `yf.download()` |
50| Balance sheet | Financial statements | `ticker.balance_sheet` |
51| Income statement, revenue | Financial statements | `ticker.income_stmt` |
52| Cash flow | Financial statements | `ticker.cashflow` |
53| Dividends | Corporate actions | `ticker.dividends` |
54| Stock splits | Corporate actions | `ticker.splits` |
55| Options chain, calls, puts | Options data | `ticker.option_chain()` |
56| Earnings, EPS | Analysis | `ticker.earnings_history` |
57| Analyst price targets | Analysis | `ticker.analyst_price_targets` |
58| Recommendations, ratings | Analysis | `ticker.recommendations` |
59| Upgrades/downgrades | Analysis | `ticker.upgrades_downgrades` |
60| Institutional holders | Ownership | `ticker.institutional_holders` |
61| Insider transactions | Ownership | `ticker.insider_transactions` |
62| Company overview, sector | General info | `ticker.info` |
63| Compare multiple stocks | Bulk download | `yf.download()` |
64| Screen/filter stocks | Screener | `yf.Screener` + `yf.EquityQuery` |
65| Sector/industry data | Market data | `yf.Sector` / `yf.Industry` |
66| News | News | `ticker.news` |
67 
68---
69 
70## Step 3: Write and Execute the Code
71 
72### General pattern
73 
74```python
75import subprocess, sys
76subprocess.check_call([sys.executable, "-m", "pip", "install", "-q", "yfinance"])
77 
78import yfinance as yf
79 
80ticker = yf.Ticker("AAPL")
81# ... use the appropriate method from the reference
82```
83 
84### Key rules
85 
861. **Always wrap in try/except** — Yahoo Finance may rate-limit or return empty data
872. **Use `yf.download()` for multi-ticker comparisons** — it's faster with multi-threading
883. **For options, list expiration dates first** with `ticker.options` before calling `ticker.option_chain(date)`
894. **For quarterly data**, use `quarterly_` prefix: `ticker.quarterly_income_stmt`, `ticker.quarterly_balance_sheet`, `ticker.quarterly_cashflow`
905. **For large date ranges**, be mindful of intraday limits — 1m data only goes back ~7 days, 1h data ~730 days
916. **Print DataFrames clearly** — use `.to_string()` or `.to_markdown()` for readability, or select key columns
927. **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.
93 
94### Valid periods and intervals
95 
96| Periods | `1d`, `5d`, `1mo`, `3mo`, `6mo`, `1y`, `2y`, `5y`, `10y`, `ytd`, `max` |
97|---|---|
98| **Intervals** | `1m`, `2m`, `5m`, `15m`, `30m`, `60m`, `90m`, `1h`, `1d`, `5d`, `1wk`, `1mo`, `3mo` |
99 
100---
101 
102## Step 4: Present the Data
103 
104After fetching data, present it clearly:
105 
1061. **Summarize key numbers** in a brief text response (current price, market cap, P/E, etc.)
1072. **Show tabular data** formatted for readability — use markdown tables or formatted DataFrames
1083. **Highlight notable items** — earnings beats/misses, unusual volume, dividend changes
1094. **Provide context** — compare to sector averages, historical ranges, or analyst consensus when relevant
110 
111If the user seems to want a chart or visualization, combine with an appropriate visualization approach (e.g., generate an HTML chart or describe the trend).
112 
113---
114 
115## Reference Files
116 
117- `references/api_reference.md` — Complete yfinance API reference with code examples for every data category
118 
119Read the reference file when you need exact method signatures or edge case handling.
120 

Discussion

Alternatives

Also in Trading modelsSee all 35 in Finance →
Networking engineer portfolio websiteCreate a professional and personalized portfolio website for a networking engineer to showcase skills, projects, and experience.Business & ops · CC0-1.0Defi protocol templatesImplement DeFi protocols with production-ready templates for staking, AMMs, governance, and flash loans. Use when building decentralized finance applications or smart contract protocols.Coding · MITQuant analystUse this agent when you need to develop quantitative trading strategies, build financial models with rigorous mathematical foundations, or conduct advanced risk analytics for derivatives and portfolios. Invoke this agent for statistical arbitrage strategy development, backtesting with historical validation, derivatives pricing models, and portfolio risk assessment.Business & ops · MITHyperliquid Reader (Read-Only)Read Hyperliquid (app.hyperliquid.xyz) perp + spot market data via opencli (read-only, public info API). Use whenever the user wants Hyperliquid perpetual or spot markets, mark/oracle/mid prices, 24h change, funding rates (hourly or annualized APR), open interest, volume, the L2 order book, OHLCV candles, historical funding, or a cross-venue funding comparison (Hyperliquid vs Binance vs Bybit) for funding arbitrage. Triggers: "Hyperliquid funding for BTC", "HL perp markets", funding on BTC perp", "Hyperliquid order book", "HL open interest", funding arb Hyperliquid vs Binance", "Hyperliquid candles for SOL", Hyperliquid spot markets", "PURR price on Hyperliquid", "hyperliquid", hyperliquid.xyz", "HL DEX". READ-ONLY market data — no account, order, or trade operations.Business & ops · MIT