yfinance

Fetch stock prices, fundamentals, options, and screener data from Yahoo Finance via Python.

Updated Mar 20, 2026
One-click install
npx skills add https://github.com/astralform-ai/skills --skill yfinance-astralform-ai
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: yfinance
Source: https://github.com/astralform-ai/skills/tree/main/skills/yfinance
Command: npx skills add https://github.com/astralform-ai/skills --skill yfinance-astralform-ai

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires yfinance, pandas, curl_cffi, lxml.

What problem does it solve? Accessing market data usually requires paid APIs or manual lookups on finance websites. This Skill retrieves quotes, historical OHLCV prices, financial statements, analyst estimates, options chains, holdings, and screener results directly from Yahoo Finance through the yfinance Python library, with no API key required. ## Core Features & Use Cases - Prices and History: Pull historical OHLCV data for equities, ETFs, indices, futures, FX, and crypto via Ticker.history() or batched yf.download(), with documented interval limits and timezone handling. - Fundamentals and Analyst Data: Access income statements, balance sheets, cash flow, earnings estimates, price targets, recommendations, and insider or institutional holdings. - Discovery and Screening: Resolve company names to tickers with yf.Search, browse sectors and industries, and run predefined or custom EquityQuery screens with proper sorting and region scoping. - Use Case: A user asks "compare AAPL and MSFT valuation and pull 1 year of daily prices." The Skill fetches adjusted close prices with yf.download, retrieves P/E and market cap from .info, and presents a normalized comparison with currency and timestamps. ## Quick Start Ask the assistant to pull the current price, market cap, and one year of daily price history for a ticker like AAPL using yfinance.

Frequently Asked Questions about yfinance

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I download historical stock data with yfinance?

Use Ticker.history(period="1y", interval="1d") for one symbol or yf.download(["AAPL", "MSFT"]) for many. Note that yf.download returns MultiIndex columns even for a single ticker; pass multi_level_index=False to get flat columns.

How do I get financial statements for a stock in Python?

Use t.income_stmt, t.balance_sheet, and t.cashflow on a yfinance Ticker object, with quarterly and TTM variants available. Line items are rows and period-end dates are columns; check membership with `in df.index` before indexing since labels vary by company.

Does yfinance require an API key?

No, yfinance requires no API key and uses Yahoo Finance's publicly available endpoints. It depends on curl_cffi to handle Yahoo's bot protection, and the earnings_dates feature additionally requires installing lxml.

Why does yfinance return an empty DataFrame?

yfinance fails silently by default, so empty DataFrames usually mean a bad or delisted symbol, or an interval range cap was exceeded (e.g., 1m data beyond 8 days). Always check df.empty and set yf.config.debug.hide_exceptions = False to raise errors instead.

Why is my yfinance screener returning irrelevant results?

Custom EquityQuery screens without a sortField return an arbitrary reverse-alphabetical slice, not the top matches. Always pass sortField (e.g., intradaymarketcap) and scope the region filter to the geography the request implies, deduplicating cross-listings on global screens.

Is yfinance data real-time and licensed for commercial use?

Yahoo data is typically delayed about 15 minutes and is not real-time. yfinance is not affiliated with Yahoo and is intended for personal and research use; commercial redistribution requires reviewing Yahoo's terms of service.