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:
If YFINANCE_NOT_INSTALLED, install it before running any code:
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.
Step 3: Write and Execute the Code
General pattern
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
Step 4: Present the Data
Answer with the numbers the user asked for first, then the supporting table (markdown, or a trimmed DataFrame with the key columns). Call out anything notable in the data — an earnings beat or miss, unusual volume, a dividend change — and add context such as sector averages, historical ranges, or analyst consensus where it changes how the numbers read. If the user wants a chart, pair the data with a visualization.
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.

