New: Earn 20% as an AgentAlley affiliate. Share your link and earn on every sale you refer. Join now New: Earn 20% as an affiliate. Join now

Fetch financial and market data using the yfinance Python

yfinance Data Skill

by himself65 · MIT license · ★ 3,347 on GitHub · updated Aug 27

yfinance Data Skill cover

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…

---
name: yfinance-data
description: >
  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](https://github.com/ranaroussi/yfinance) Python library.

Overview

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

Manual install (npx, ZIP)
Claude Codenpx skills add himself65/finance-skills --skill yfinance-data -g -a claude-code
Claude Code (manual)mkdir -p ~/.claude/skills && curl -sL https://codeload.github.com/himself65/finance-skills/tar.gz/0a5759bca1ea \ | tar -xz -C ~/.claude/skills --strip-components=4 finance-skills-0a5759bca1ea/plugins/market-analysis/skills/yfinance-data
Windows (PowerShell)New-Item -ItemType Directory -Force "$HOME\.claude\skills" | Out-Null; Invoke-WebRequest "https://m.agentalley.io/zip/2dcfb4fdad5a29927d3f/yfinance-data.zip" -OutFile "$env:TEMP\yfinance-data.zip"; Expand-Archive "$env:TEMP\yfinance-data.zip" -DestinationPath "$HOME\.claude\skills" -Force
Claude.ai / desktopDownload the ZIP and upload it under Settings → Capabilities → Skills.
Codex, Cursor, other agentsPoint them at SKILL.md. The other files are plain text.

Connects with Agent Alley MCP · agentalley.io/mcp

Files included

  • SKILL.md5.2 KB
  • README.md1.7 KB
  • references/1 file · 8.8 KB
Read the files here
himself65/0a5759b3 files
SKILL.md
Show the full text120 lines

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 
View all files on GitHub →

Details

Updated
Aug 27, 2026
License
MIT
Stars on the repo
★ 3,347
Checked
Source
himself65/finance-skills ↗
Creator
himself65 · 24 listings
View creator

Similar skills

See all →
PromptCreate a professional and personalized portfolio websiteNetworking engineer portfolio websitef/prompts.chat · by AliHusham144Create a professional and personalized portfolio website for a networking engineer to showcase skills, projects, and experience.New listingMCPBuild financial models, backtest trading strategiesQuant analystwshobson/agents · by wshobsonBuild financial models, backtest trading strategies, and analyze market data. Implements risk metrics, portfolio optimization, and statistical arbitrage. Use PROACTIVELY for quantitative finance, trading algorithms, or risk analysis.★ 39.9k GitHub starsMCPMonitor portfolio risk, R-multiples, and position limitsRisk managerwshobson/agents · by wshobsonMonitor portfolio risk, R-multiples, and position limits. Creates hedging strategies, calculates expectancy, and implements stop-losses. Use PROACTIVELY for risk assessment, trade tracking, or portfolio protection.★ 39.9k GitHub starsSkillExpert in building portfolios that actually land jobsInteractive portfoliodavila7/claude-code-templates · by davila7Expert in building portfolios that actually land jobs and clients - not just showing work, but creating memorable experiences. Covers developer portfolios, designer portfolios, creative portfolios, and portfolios that convert visitors into opportunities. Use when: portfolio, personal website, showcase work, developer portfolio, designer portfolio.★ 32.3k GitHub starsMCPYou need to develop quantitative trading strategiesQuant analystVoltAgent/awesome-claude-code-subagents · by VoltAgentUse 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.★ 25.2k GitHub starsSkillRead Hyperliquid perp + spot market data via opencliHyperliquid Reader (Read-Only)himself65/finance-skills · by himself65Read 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.★ 3.3k GitHub stars

More from himself65

SkillEstimate the intrinsic value of a public company using DCFCompany valuationhimself65/finance-skills · by himself65Estimate the intrinsic value of a public company using DCF, relative (peer multiple) and sum-of-parts (SOTP) methods, then triangulate to an implied share price with upside/downside versus the current market price. Use this skill whenever the user asks: what is AAPL worth", "valuation of NVDA", "fair value of TSLA", "intrinsic value", DCF for MSFT", "build a DCF", "discounted cash flow", "WACC", "terminal value", implied share price", "upside to fair value", "is X overvalued/undervalued", relative valuation", "peer comparison valuation", "EV/EBITDA target", "SOTP", sum of the parts", "how much is [company] worth", "price target from fundamentals", value this company", or any ticker in the context of computing intrinsic or relative valuation. Default to running ALL three methods (DCF + relative + SOTP-if-applicable) and presenting a blended implied price with a sensitivity table. Do not answer valuation questions from memory — always run the workflow.★ 3.3k GitHub starsSkillRead Discord for financial research using opencliDiscord Skill (Read-Only)himself65/finance-skills · by himself65Read Discord for financial research using opencli (read-only). Use this skill whenever the user wants to read Discord channels, search for messages in trading servers, view guild/channel info, monitor crypto or market discussion groups, or gather financial sentiment from Discord. Triggers include: "check my Discord", "search Discord for", "read Discord messages", what's happening in the trading Discord", "show Discord channels", "list my servers", Discord sentiment on BTC", "what are people saying in Discord about AAPL", monitor crypto Discord", any mention of Discord in context of reading financial news, market research, or trading community discussions. This skill is READ-ONLY — it does NOT support sending messages, reacting, or any write operations.★ 3.3k GitHub starsSkillGenerate a pre-earnings briefing for any stock using YahooEarnings Preview Skillhimself65/finance-skills · by himself65Generate a pre-earnings briefing for any stock using Yahoo Finance data. Use this skill whenever the user wants to prepare for an upcoming earnings report, understand what analysts expect, review a company's beat/miss track record, or get a quick overview before an earnings call. Triggers include: "earnings preview for AAPL", "what to expect from TSLA earnings", MSFT reports next week", "earnings preview", "pre-earnings analysis", what are analysts expecting for NVDA", "earnings estimates for", will GOOGL beat earnings", "earnings beat/miss history", upcoming earnings", "before earnings", "earnings setup", consensus estimates", "earnings whisper", "EPS expectations", what's the street expecting", "earnings season preview", any mention of preparing for or previewing an earnings report, or any request to understand expectations ahead of a company's earnings date. Always use this skill when the user mentions a ticker in context of upcoming earnings, even if they don't say "preview" explicitly.★ 3.3k GitHub starsSkillGenerate a post-earnings analysis for any stock using YahooEarnings Recap Skillhimself65/finance-skills · by himself65Generate a post-earnings analysis for any stock using Yahoo Finance data. Use when the user wants to review what happened after earnings, understand beat/miss results, see stock reaction, or get an earnings recap. Triggers: "AAPL earnings recap", "how did TSLA earnings go", "MSFT earnings results", did NVDA beat earnings", "post-earnings analysis", "earnings surprise", what happened with GOOGL earnings", "earnings reaction", stock moved after earnings", "EPS beat or miss", "revenue beat or miss", quarterly results for", "how were earnings", "AMZN reported last night", earnings call recap", or any request about a company's recent earnings outcome. Use this skill when the user references a past earnings event, even if they just say "AAPL reported" or "how did they do".★ 3.3k GitHub starsSkillDeep-dive into analyst estimates and revision trends for anyEstimate Analysis Skillhimself65/finance-skills · by himself65Deep-dive into analyst estimates and revision trends for any stock using Yahoo Finance data. Use when the user wants to understand analyst estimate direction, how EPS or revenue forecasts changed over time, compare estimate distributions, or analyze growth projections across periods. Triggers: "estimate analysis for AAPL", "analyst estimate trends for NVDA", EPS revisions for TSLA", "how have estimates changed for MSFT", estimate revisions", "EPS trend", "revenue estimates", consensus changes", "analyst estimates", "estimate distribution", growth estimates for", "estimate momentum", "revision trend", forward estimates", "next quarter estimates", "annual estimates", estimate spread", "bull vs bear estimates", "estimate range", or any request about tracking or comparing analyst estimates/revisions. Use this skill when the user asks about estimates beyond a simple lookup — if they want context, trends, or analysis, this is the right skill.★ 3.3k GitHub starsSkillCalculate ETF premium/discount vs NAV via Yahoo FinanceETF Premium/Discount Analysis Skillhimself65/finance-skills · by himself65Calculate ETF premium/discount vs NAV via Yahoo Finance, and decompose single-day surges into NAV-driven vs structural components (gamma squeeze, dealer hedging, blocked AP arbitrage). Use whenever the user asks about an ETF's premium or discount, NAV comparison, why an ETF diverged from its holdings, or how much of a move is dealer-hedging-driven. Triggers: "ETF premium", "ETF discount", "NAV premium", "is SPY at a premium", "BITO premium", IBIT premium", "bond ETF discount", "trading above/below NAV", "ETF premium screener", biggest discount", "compare ETF NAV", "ETF arbitrage", "ETF gamma squeeze", ETF premium surge", "decompose ETF move", "dealer gamma exposure", "GEX for ETF", why did this ETF jump", "premium convergence", "AP arbitrage blocked", or any request about the gap between an ETF's price and underlying value. Especially relevant for leveraged, inverse, international, bond, commodity, and crypto ETFs.★ 3.3k GitHub stars