yfinance Data Skill
Fetch financial and market data using the yfinance Python library.
How to use it
Claude Code
- Run the line below. It pulls the whole folder into
~/.claude/skills/yfinance-data. - Describe your job in plain words. Claude Code follows the skill from there.
npx degit himself65/finance-skills/plugins/market-analysis/skills/yfinance-data#main ~/.claude/skills/yfinance-dataFor one project only, change the path to .claude/skills/yfinance-data.
Claude (web or desktop app)
- On this page open ⋯ → Download .md.
- Save it as SKILL.md in a folder, zip the folder, then Customize → Skills → + → Create skill → Upload a skill.
- Pick the file and Save. Claude shows the name and description and runs a security scan.
- Check the skill is switched on.
- Start a new chat and describe your job in plain words. The AI follows the skill from there.
ChatGPT or another app
- ChatGPT: make a Project and paste it into Instructions.
- 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.
Paste into Claude, ChatGPT or Cursor.
Source of yfinance Data Skill
Show the full text120 lines
| name | description |
|---|---|
| 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
- Always wrap in try/except — Yahoo Finance may rate-limit or return empty data
- Use
yf.download()for multi-ticker comparisons — it's faster with multi-threading - For options, list expiration dates first with
ticker.optionsbefore callingticker.option_chain(date) - For quarterly data, use
quarterly_prefix:ticker.quarterly_income_stmt,ticker.quarterly_balance_sheet,ticker.quarterly_cashflow - For large date ranges, be mindful of intraday limits — 1m data only goes back ~7 days, 1h data ~730 days
- Print DataFrames clearly — use
.to_string()or.to_markdown()for readability, or select key columns - Timezone handling — yfinance returns tz-aware datetime indices (e.g.,
America/New_York). When comparing dates, always usepd.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:
- Summarize key numbers in a brief text response (current price, market cap, P/E, etc.)
- Show tabular data formatted for readability — use markdown tables or formatted DataFrames
- Highlight notable items — earnings beats/misses, unusual volume, dividend changes
- 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 | |
| 2 | name yfinance-data |
| 3 | description > |
| 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 | |
| 17 | Fetches financial and market data from Yahoo Finance using the [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 | |
| 31 | If `YFINANCE_NOT_INSTALLED`, install it before running any code: |
| 32 | |
| 33 | |
| 34 | import subprocess, sys |
| 35 | subprocess.check_call([sys.executable, "-m", "pip", "install", "-q", "yfinance"]) |
| 36 | |
| 37 | |
| 38 | If yfinance is already installed, skip the install step and proceed directly. |
| 39 | |
| 40 | |
| 41 | |
| 42 | ## Step 2: Identify What the User Needs |
| 43 | |
| 44 | Match 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 | |
| 75 | import subprocess, sys |
| 76 | subprocess.check_call([sys.executable, "-m", "pip", "install", "-q", "yfinance"]) |
| 77 | |
| 78 | import yfinance as yf |
| 79 | |
| 80 | ticker = yf.Ticker("AAPL") |
| 81 | # ... use the appropriate method from the reference |
| 82 | |
| 83 | |
| 84 | ### Key rules |
| 85 | |
| 86 | **Always wrap in try/except** — Yahoo Finance may rate-limit or return empty data |
| 87 | **Use `yf.download()` for multi-ticker comparisons** — it's faster with multi-threading |
| 88 | **For options, list expiration dates first** with `ticker.options` before calling `ticker.option_chain(date)` |
| 89 | **For quarterly data**, use `quarterly_` prefix: `ticker.quarterly_income_stmt`, `ticker.quarterly_balance_sheet`, `ticker.quarterly_cashflow` |
| 90 | **For large date ranges**, be mindful of intraday limits — 1m data only goes back ~7 days, 1h data ~730 days |
| 91 | **Print DataFrames clearly** — use `.to_string()` or `.to_markdown()` for readability, or select key columns |
| 92 | **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 | |
| 104 | After fetching data, present it clearly: |
| 105 | |
| 106 | **Summarize key numbers** in a brief text response (current price, market cap, P/E, etc.) |
| 107 | **Show tabular data** formatted for readability — use markdown tables or formatted DataFrames |
| 108 | **Highlight notable items** — earnings beats/misses, unusual volume, dividend changes |
| 109 | **Provide context** — compare to sector averages, historical ranges, or analyst consensus when relevant |
| 110 | |
| 111 | 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). |
| 112 | |
| 113 | |
| 114 | |
| 115 | ## Reference Files |
| 116 | |
| 117 | `references/api_reference.md` — Complete yfinance API reference with code examples for every data category |
| 118 | |
| 119 | Read the reference file when you need exact method signatures or edge case handling. |
| 120 |
Discussion
Browse more free Claude skills or everything in Finance.