Pull Stock Price Data Using Yahoo Finance and Python and Visualize It

Python and yfinance library make it easy to download stock price data. This post will show you how to get Nvidia's stock price data and visualize it.

Image by Alethea Flowers from Pixabay

Start with importing the required packages:

#import packages:
import pandas as pd
import pandas_datareader.data as web
import datetime as dt
import matplotlib.pyplot as plt
import yfinance as yf
import finplot as fplt

Get Nvidia (NVDA) stock price data using yfinance library between 22 January 1999 and 04 June 2023:

#query the data:
nvda = yf.download('NVDA', start='1999-01-22', end='2023-06-04')
Advertisements

Check everything is alright with the data frame:

#look at the top of the data frame
nvda.head()
#look at the bottom of the data frame
nvda.tail()

And finally visualize the data:

#candle-stick chart for Nvidia's Stock Prices
fplt.candlestick_ochl(nvda[['Open','Close','High','Low']])
fplt.show()

The whole picture:

NVDA Stock Prices over 22 January 1999 - 04 June 2023

Zoom in and look at the last two years:

NVDA Stock Prices over 01 December 2021 - 04 June 2023

Thanks for reading!

Check out this book to improve your Python skills on financial analysis:

Leave a Reply

Discover more from Cenk Yildiran

Subscribe now to keep reading and get access to the full archive.

Continue reading