Download winPython and open the spyder to install the yfinance at first
pip install yfinance
Launch Jupyter notebook and create a new one as below
More details Python and Yfinance can provide
xxxxxxxxxx
181import yfinance as yf
2import matplotlib.pyplot as plt
3import numpy as np
4import pandas as pd
5
6# define the ticker symbol
7tickerSymbol = 'MSFT'
8
9# get data on this ticker
10tickerData = yf.Ticker(tickerSymbol)
11
12# get the historical prices for this ticker
13tickerDf = tickerData.history(period='1d', start='2018-1-1', end='2021-5-30')
14
15# see data
16tickerDf
17
xxxxxxxxxx
61tickerDf['Close'].plot()
2plt.xlabel("Date")
3plt.ylabel("Close")
4plt.title("Miscrosoft Price data")
5plt.style.use('dark_background')
6plt.show()
xxxxxxxxxx
21# info on the company
2tickerData.info
xxxxxxxxxx
21# get event data for ticker
2tickerData.calendar
0 | 1 | |
---|---|---|
Earnings Date | 2021-07-20 00:00:00 | 2021-07-26 00:00:00 |
Earnings Average | 1.9 | 1.9 |
Earnings Low | 1.64 | 1.64 |
Earnings High | 2.03 | 2.03 |
Revenue Average | 44105500000 | 44105500000 |
Revenue Low | 40850000000 | 40850000000 |
Revenue High | 45019500000 | 45019500000 |
xxxxxxxxxx
21# get recommendation data for ticker
2tickerData.recommendations
No comments:
Post a Comment