1#In your command prompt first run: pip install yfinance
2
3import yfinance as yf
4
5msft = yf.Ticker("MSFT")
6
7# get stock info
8msft.info
9
10# get historical market data
11hist = msft.history(period="max")
12
13# show actions (dividends, splits)
14msft.actions
15
16# show dividends
17msft.dividends
18
19# show splits
20msft.splits
21
22# show financials
23msft.financials
24msft.quarterly_financials
25
26# show major holders
27msft.major_holders
28
29# show institutional holders
30msft.institutional_holders
31
32# show balance sheet
33msft.balance_sheet
34msft.quarterly_balance_sheet
35
36# show cashflow
37msft.cashflow
38msft.quarterly_cashflow
39
40# show earnings
41msft.earnings
42msft.quarterly_earnings
43
44# show sustainability
45msft.sustainability
46
47# show analysts recommendations
48msft.recommendations
49
50# show next event (earnings, etc)
51msft.calendar
52
53# show ISIN code - *experimental*
54# ISIN = International Securities Identification Number
55msft.isin
56
57# show options expirations
58msft.options
59
60# get option chain for specific expiration
61opt = msft.option_chain('YYYY-MM-DD')
62# data available via: opt.calls, opt.puts
1#In your command prompt you first need to install yfinance by running:
2#pip install yfinance
3import yfinance as yf
4AAPL = yf.Ticker('AAPL').history('5y')