Yfinance Data

himself65/finance-skills/plugins/market-analysis/skills/yfinance-data

作者 himself6501fc7b4b34ae無授權條款3.3K 個星標收錄於 2026年10月8日更新於 2026年10月8日儲存庫4 天前更新

Fetch financial and market data with the yfinance Python library (Yahoo Finance). Use this skill whenever the user wants stock data: current quotes and price history, financial statements (income statement, balance sheet, cash flow), options chains, dividends and splits, earnings and analyst estimates, price targets and ratings, institutional and insider holdings, news, multi-ticker comparisons, stock screens, or sector and industry data. Use it even when the user gives only a ticker symbol (AAPL, MSFT, TSLA) and the intent has to be inferred. For earnings previews or recaps, estimate revisions, valuation, correlation, liquidity, or ETF premium analysis, prefer the dedicated skill.

AI 產生的概覽

透過 yfinance Python 函式庫從 Yahoo Finance 取得股票與市場資料並加以呈現。

功能
引導代理安裝並使用 yfinance Python 函式庫,從 Yahoo Finance 抓取金融與市場資料。它會把使用者需求對應到各類資料,例如報價、價格歷史、財務報表、選擇權鏈、股利與股票分割、盈餘、分析師預估、持股、新聞、多檔股票比較、篩選,以及產業與類股資料。接著由代理撰寫並執行程式碼,處理速率限制與時區問題,並以輔助表格和背景資訊呈現數字。
適用情境
當使用者需要股票或市場資料時使用,包括只提供股票代號、必須推斷意圖的情況。它涵蓋報價、價格歷史、財務報表、選擇權、公司行動、分析師與持股資料、新聞、比較、篩選以及產業資料。此技能指出,盈餘預覽或回顧、預估修正、估值、相關性、流動性以及 ETF 溢價分析更適合由專門的技能處理。
執行需求
需要 yfinance Python 函式庫(缺少時以 pip 安裝),以及可連線至 Yahoo Finance 的 Python 3 網路環境。它不附帶指令碼,只有說明文件與一份參考檔案。資料被說明為僅供研究與教育用途,並註明 yfinance 與 Yahoo 並無關聯。

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:

python
import subprocess, syssubprocess.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 RequestData CategoryPrimary Method
Stock price, quoteCurrent priceticker.info or ticker.fast_info
Price history, chart dataHistorical OHLCVticker.history() or yf.download()
Balance sheetFinancial statementsticker.balance_sheet
Income statement, revenueFinancial statementsticker.income_stmt
Cash flowFinancial statementsticker.cashflow
DividendsCorporate actionsticker.dividends
Stock splitsCorporate actionsticker.splits
Options chain, calls, putsOptions dataticker.option_chain()
Earnings, EPSAnalysisticker.earnings_history
Analyst price targetsAnalysisticker.analyst_price_targets
Recommendations, ratingsAnalysisticker.recommendations
Upgrades/downgradesAnalysisticker.upgrades_downgrades
Institutional holdersOwnershipticker.institutional_holders
Insider transactionsOwnershipticker.insider_transactions
Company overview, sectorGeneral infoticker.info
Compare multiple stocksBulk downloadyf.download()
Screen/filter stocksScreeneryf.screen() + yf.EquityQuery
Sector/industry dataMarket datayf.Sector / yf.Industry
NewsNewsticker.news

Step 3: Write and Execute the Code

General pattern

python
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

Periods1d, 5d, 1mo, 3mo, 6mo, 1y, 2y, 5y, 10y, ytd, max
Intervals1m, 2m, 5m, 15m, 30m, 60m, 90m, 1h, 1d, 5d, 1wk, 1mo, 3mo

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.

來源與署名

來源:himself65/finance-skills位於plugins/market-analysis/skills/yfinance-data提交01fc7b4

授權條款: 無授權條款

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架

更多來自 himself65/finance-skills 的技能

Stock Liquidity

himself65

Analyze how liquid a stock is using Yahoo Finance data (yfinance): bid-ask spreads, volume and dollar volume (ADTV), top-of-book and options depth, square-root market impact and slippage estimates, turnover ratio, and Amihud illiquidity, rolled into a liquidity grade. Use this skill whenever the user asks about liquidity or trading costs — how easily a position can be entered or exited, what a large order would do to the price, spread or execution-cost estimates, order book depth, volume patterns, or liquidity comparisons — especially for small caps, penny stocks, and thinly traded names.

待分類3.3K4 天前更新

Stock Correlation

himself65

以 Yahoo Finance 價格歷史分析股票連動,找出相關個股、貝他、聚類與滾動相關性。

Data & Analytics3.3K4 天前更新

Sepa Strategy

himself65

以 Mark Minervini 的 SEPA 方法分析股票:階段分析、趨勢範本、型態、進場點與部位控管。

Business & Finance3.3K4 天前更新

Saas Valuation Compression

himself65

分析未上市 SaaS 公司各輪募資的 ARR 估值倍數變化,並將變化歸因於總經、成長與敘事因素。

Business & Finance3.3K4 天前更新

Yc Reader

himself65

Look up Y Combinator companies and batches from the public yc-oss API, a static JSON dataset refreshed daily: company profiles, batch rosters (e.g. W25, S24), companies by industry or tag, top companies, who is hiring, founder-diversity lists, and overall YC stats. Use this skill whenever the user asks about YC-backed startups, a YC batch, YC companies in a sector or tag or that are hiring, the Y Combinator portfolio, or startup and venture research that draws on YC data. Read-only.

待分類3.3K4 天前更新

Twitter Reader

himself65

透過 opencli 命令列以唯讀方式讀取 Twitter/X 進行金融研究:時間軸、搜尋、趨勢、書籤、個人檔案與通知。

Research & Analysis3.3K4 天前更新