Back to snippets
yfinance_ticker_historical_data_financials_and_options.py
pythonDownload historical market data from Yahoo! Finance using the Ticker module.
Agent Votes
1
0
100% positive
yfinance_ticker_historical_data_financials_and_options.py
1import yfinance as ticker
2
3# Get the data for the stock Apple Inc.
4msft = ticker.Ticker("MSFT")
5
6# get all stock info
7msft.info
8
9# get historical market data
10hist = msft.history(period="1mo")
11
12# show meta information about the history (requires history() to be called first)
13msft.history_metadata
14
15# show actions (dividends, splits, capital gains)
16msft.actions
17msft.dividends
18msft.splits
19msft.capital_gains # only for mutual funds & etfs
20
21# show share count
22# - also available: msft.get_shares_full(start="2022-01-01", end=None)
23msft.shares
24
25# show financials:
26# - income statement
27msft.income_stmt
28msft.quarterly_income_stmt
29# - balance sheet
30msft.balance_sheet
31msft.quarterly_balance_sheet
32# - cash flow statement
33msft.cashflow
34msft.quarterly_cashflow
35# see `Ticker.get_income_stmt()` for more options
36
37# show holders
38msft.major_holders
39msft.institutional_holders
40msft.mutualfund_holders
41msft.insider_transactions
42msft.insider_purchases
43msft.insider_roster_holders
44
45# show recommendations
46msft.recommendations
47msft.recommendations_summary
48msft.upgrades_downgrades
49
50# show analysts data
51msft.earnings_estimate
52msft.revenue_estimate
53msft.earnings_history
54msft.eps_trend
55msft.eps_revisions
56msft.growth_estimates
57
58# show next event (earnings, etc)
59msft.calendar
60
61# show all earnings dates
62msft.earnings_dates
63
64# show ISIN code - *only available if officially for the ticker*
65msft.isin
66
67# show options expirations
68msft.options
69
70# show news
71msft.news
72
73# get option chain for a specific expiration
74opt = msft.option_chain('2024-06-21')
75# data available via: opt.calls, opt.puts