Skillsyfinance-data
Y

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 - Using Python to Obtain Yahoo Finance Stock Data

Skill Overview

The yfinance Data skill allows AI agents to directly call Python’s yfinance library to retrieve stock quotes, historical candlestick data, financial statements, options chains, dividend and stock split records, earnings data, and analyst ratings from Yahoo Finance. No API key is required—data can be retrieved simply by providing a stock ticker.

Applicable Scenarios

  1. Investment research and financial statement analysis: Enter tickers such as AAPL, MSFT, or TSLA to retrieve income statements, balance sheets, and cash flow statements, including quarterly data, in one go. This can be used to compare changes in revenue, gross margins, and cash flow, and quickly prepare a comprehensive financial analysis draft.
  2. Data preparation for quantitative backtesting: Download daily, weekly, or minute-level OHLCV data using the period and interval parameters. Multiple securities can be downloaded in batches and aligned on a common timeline, then fed directly into backtesting or factor-analysis scripts.
  3. Connecting agents to real-time market data: When you ask questions such as “How much is a particular stock trading at now?”, “What rating changes have occurred recently?”, or “Are institutions increasing or reducing their positions?”, the skill automatically supplements the answer with the current price, analyst price targets, institutional holdings, and insider transactions, ensuring that responses are based on real data rather than memory.

Core Features

  1. Quotes and historical data: Current quotes are retrieved through ticker.info / ticker.fast_info, while historical candlestick data is retrieved through ticker.history() or yf.download(). The former is suitable for detailed retrieval of a single security, while the latter uses multithreading to download data for multiple stocks more quickly. Available periods range from 1d to max, and available intervals range from 1m to 3mo.
  2. Financial and corporate action data: income_stmt, balance_sheet, and cashflow provide the three major financial statements. Adding the quarterly_ prefix retrieves quarterly data. dividends and splits provide historical dividend and stock split records, making them suitable for calculating adjusted returns and dividend yields.
  3. Derivatives, ratings, and screening: option_chain() retrieves call and put option chains by expiration date. analyst_price_targets, recommendations, upgrades_downgrades, institutional_holders, and insider_transactions cover analyst opinions and capital flows. yf.Screener combined with yf.EquityQuery can screen stocks based on specified criteria, while yf.Sector / yf.Industry can retrieve sector- and industry-level data.

Frequently Asked Questions

Does yfinance require an API key? Is it free?

No API key is required, and it is free to use. Once the Python package is installed, it can be called directly. For this reason, Yahoo does not provide guaranteed quota commitments, so the skill is implemented to catch exceptions for each request and degrade gracefully when rate limits are encountered or empty data is returned, rather than failing outright. If you need commercial or high-frequency access, you should first verify Yahoo’s terms of use independently.

Is the data real-time or delayed?

Quotes and market data come from Yahoo Finance’s public interfaces and are generally subject to varying degrees of delay, making them unsuitable as a basis for trade execution. Their intended use is research and education. The skill also clearly states the limitations of the data: yfinance is not affiliated with Yahoo, Inc., and the data is for research and educational purposes only.

How far back can minute-level historical data go?

Due to upstream limitations, 1m data can generally be retrieved only for approximately the most recent 7 days, while 1h data covers roughly 730 days. Daily and higher intervals can use max to retrieve the full historical record. For long-term backtesting, daily or weekly data should be used. For intraday data, it is best to retrieve and cache the data locally during each run rather than relying on long-term historical access.

What common pitfalls should be avoided when retrieving data?

The three most common issues are: first, time zones. yfinance returns a time zone–aware DatetimeIndex, such as America/New_York, so time zones should be standardized before comparing dates across time zones, or tz_localize(None) can be used to remove the time zone. Second, for options, you must first read ticker.options to obtain the list of expiration dates, and then use option_chain(date) to retrieve a specific chain. Third, quarterly financial data requires interfaces with the quarterly_ prefix; using the default interfaces directly returns annual data.

How do you trigger this skill?

There is no need to remember interface names—simply ask a question in natural language. For example: “Help me review NVDA’s latest financial results,” “Show me TSLA’s options chain,” “Compare the performance of AAPL and MSFT over the past year,” or “Which stocks meet my screening criteria?” The skill will automatically match your intent to the appropriate data-retrieval method. Even if you provide only a stock ticker, it will infer from the context whether you are looking for market data, financial statements, or ratings.