Ticker#
- class yfinance.Ticker(ticker, session=None)#
Initialize a Yahoo Finance Ticker object.
- Parameters:
ticker (str | tuple[str, str]) – Yahoo Finance symbol (e.g. “AAPL”) or a tuple of (symbol, MIC) e.g. (‘OR’,’XPAR’) (MIC = market identifier code)
session (requests.Session, optional) – Custom requests session.
Attributes
- actions
- analyst_price_targets
- balance_sheet
- balancesheet
- calendar
Returns a dictionary of events, earnings, and dividends for the ticker
- capital_gains
- cash_flow
- cashflow
- dividends
- earnings
- earnings_dates
- earnings_estimate
- earnings_history
- eps_revisions
- eps_trend
- fast_info
- financials
- funds_data
- growth_estimates
- history_metadata
- income_stmt
- incomestmt
- info
- insider_purchases
- insider_roster_holders
- insider_transactions
- institutional_holders
- isin
- major_holders
- mutualfund_holders
- news
- options
- quarterly_balance_sheet
- quarterly_balancesheet
- quarterly_cash_flow
- quarterly_cashflow
- quarterly_earnings
- quarterly_financials
- quarterly_income_stmt
- quarterly_incomestmt
- recommendations
- recommendations_summary
- revenue_estimate
- sec_filings
- shares
- splits
- sustainability
- ttm_cash_flow
- ttm_cashflow
- ttm_financials
- ttm_income_stmt
- ttm_incomestmt
- upgrades_downgrades
- valuation
Methods
- __init__(ticker, session=None)
Initialize a Yahoo Finance Ticker object.
- Parameters:
ticker (str | tuple[str, str]) – Yahoo Finance symbol (e.g. “AAPL”) or a tuple of (symbol, MIC) e.g. (‘OR’,’XPAR’) (MIC = market identifier code)
session (requests.Session, optional) – Custom requests session.
- get_actions(period='max') Series
- get_analyst_price_targets() dict
Keys: current low high mean median
- get_balance_sheet(as_dict=False, pretty=False, freq='yearly')
- Parameters:
- as_dict: bool
Return table as Python dict Default is False
- pretty: bool
Format row names nicely for readability Default is False
- freq: str
“yearly” or “quarterly” Default is “yearly”
- get_balancesheet(as_dict=False, pretty=False, freq='yearly')
- get_calendar() dict
- get_capital_gains(period='max') Series
- get_cash_flow(as_dict=False, pretty=False, freq='yearly') DataFrame | dict
- Parameters:
- as_dict: bool
Return table as Python dict Default is False
- pretty: bool
Format row names nicely for readability Default is False
- freq: str
“yearly” or “quarterly” Default is “yearly”
- get_cashflow(as_dict=False, pretty=False, freq='yearly')
- get_dividends(period='max') Series
- get_earnings(as_dict=False, freq='yearly')
- Parameters:
- as_dict: bool
Return table as Python dict Default is False
- freq: str
“yearly” or “quarterly” or “trailing” Default is “yearly”
- get_earnings_dates(limit=12, offset=0) DataFrame | None
- get_earnings_estimate(as_dict=False, methodology=None)
Index: 0q +1q 0y +1y Columns: numberOfAnalysts avg low high yearAgoEps growth currency methodology
- Parameters:
- methodologystr
EPS methodology: ‘gaap’ or ‘normalized’ (non-GAAP). Default None = Yahoo’s default for the ticker, reported in column ‘methodology’.
- get_earnings_history(as_dict=False, methodology=None)
Index: pd.DatetimeIndex Columns: epsEstimate epsActual epsDifference surprisePercent methodology
- Parameters:
- methodologystr
EPS methodology: ‘gaap’ or ‘normalized’ (non-GAAP). Default None = Yahoo’s default for the ticker, reported in column ‘methodology’.
- get_eps_revisions(as_dict=False, methodology=None)
Index: 0q +1q 0y +1y Columns: upLast7days upLast30days downLast7days downLast30days currency methodology
- Parameters:
- methodologystr
EPS methodology: ‘gaap’ or ‘normalized’ (non-GAAP). Default None = Yahoo’s default for the ticker, reported in column ‘methodology’.
- get_eps_trend(as_dict=False, methodology=None)
Index: 0q +1q 0y +1y Columns: current 7daysAgo 30daysAgo 60daysAgo 90daysAgo currency methodology
- Parameters:
- methodologystr
EPS methodology: ‘gaap’ or ‘normalized’ (non-GAAP). Default None = Yahoo’s default for the ticker, reported in column ‘methodology’.
- get_fast_info()
- get_financials(as_dict=False, pretty=False, freq='yearly')
- get_funds_data() FundsData | None
- get_growth_estimates(as_dict=False)
Index: 0q +1q 0y +1y +5y -5y Columns: stock industry sector index
- get_history_metadata(repair=<object object>) dict
repair default value depends on whether user requested price repair with previous history() call. If user did not set repair here, then it is set to match previous history() call.
- get_income_stmt(as_dict=False, pretty=False, freq='yearly')
- Parameters:
- as_dict: bool
Return table as Python dict Default is False
- pretty: bool
Format row names nicely for readability Default is False
- freq: str
“yearly” or “quarterly” or “trailing” Default is “yearly”
- get_incomestmt(as_dict=False, pretty=False, freq='yearly')
- get_info() dict
- get_insider_purchases(as_dict=False)
- get_insider_roster_holders(as_dict=False)
- get_insider_transactions(as_dict=False)
- get_institutional_holders(as_dict=False)
- get_isin() str | None
- get_major_holders(as_dict=False)
- get_mutualfund_holders(as_dict=False)
- get_news(count=10, tab='news') list
Get the latest news for the ticker, newest first.
News follows
yf.config.locale. Yahoo only has news for some locales; for others an empty list is returned.- Parameters:
count (int) – Maximum number of articles to return
tab (str) – “news”, “all” or “press releases”
- Returns:
list of articles, each
{"id": ..., "content": {...}}
- get_recommendations(as_dict=False)
Returns a DataFrame with the recommendations Columns: period strongBuy buy hold sell strongSell
- get_recommendations_summary(as_dict=False)
- get_revenue_estimate(as_dict=False)
Index: 0q +1q 0y +1y Columns: numberOfAnalysts avg low high yearAgoRevenue growth
- get_sec_filings() dict
- get_shares(as_dict=False) DataFrame | dict
- get_shares_full(start=None, end=None)
- get_splits(period='max') Series
- get_sustainability(as_dict=False)
- get_upgrades_downgrades(as_dict=False)
Returns a DataFrame with the recommendations changes (upgrades/downgrades) Index: date of grade Columns: firm toGrade fromGrade action
- get_valuation_measures(freq='quarterly', periods=5) DataFrame
Valuation measures (market cap, P/E, P/S, P/B, EV/EBITDA, …).
Returns a DataFrame with the 9 valuation measures as rows and a
Currentcolumn plus period-end date columns (newest first). Values are raw numeric measures (floats, withNaNfor missing cells); the date column labels remain"M/D/YYYY"strings.- Parameters:
freq – period columns to return — “quarterly” (default), “monthly”, “yearly” or “trailing”. The “Current” column always reflects the latest trailing value.
periods – cap on the number of period (date) columns returned, newest first. An int >= 0 or None. The default of 5 matches the column count the old key-statistics page showed;
periods=0returns only the “Current” column;Nonereturns all available history. Thevaluationproperty uses this default — call the method form to controlperiods.
- history(*args, **kwargs) DataFrame
- live(message_handler=None, verbose=True)
- option_chain(date: str | None = None, tz: str | Any | None = None) Options