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
xxxxxxxxxx181import yfinance as yf2import matplotlib.pyplot as plt3import numpy as np4import pandas as pd56# define the ticker symbol7tickerSymbol = 'MSFT'89# get data on this ticker10tickerData = yf.Ticker(tickerSymbol)1112# get the historical prices for this ticker13tickerDf = tickerData.history(period='1d', start='2018-1-1', end='2021-5-30')1415# see data16tickerDf17
xxxxxxxxxx61tickerDf['Close'].plot()2plt.xlabel("Date")3plt.ylabel("Close")4plt.title("Miscrosoft Price data")5plt.style.use('dark_background')6plt.show()
xxxxxxxxxx21# info on the company2tickerData.infoxxxxxxxxxx21# get event data for ticker2tickerData.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 |
xxxxxxxxxx21# get recommendation data for ticker2tickerData.recommendations
No comments:
Post a Comment