How to Integrate Yahoo Finance API with Matplotlib

In this article we want to learn about How to Integrate Yahoo Finance API with Matplotlib, so If you are interested in financial data analysis, you might find yourself needing to use Yahoo Finance data. Yahoo Finance is free and widely used platform that provides financial information on different stocks, currencies, commodities and indices. in this article we want to learn how to integrate Yahoo Finance with Matplotlib to create graphs and charts based on financial data.

 

 

First of all we need to install required libraries.

 

 

Now we can access Yahoo Finance data using yfinance library. yfinance library is popular and easy Python library that allows you to download historical market data from Yahoo Finance.

In the above example we are downloading Apple’s stock data from January 1, 2020, to April 1, 2022. data will be stored in pandas dataframe.

 

 

This will be the result

How to Integrate Yahoo Finance API with Matplotlib
How to Integrate Yahoo Finance with Matplotlib

 

 

Now that we have the data, we can use Matplotlib to create a chart of the stock closing price. we can do this by plotting the closing price against the date.

In this example we are have created line plot of Apple’s stock price against the date. we set the title and axis labels and then show the chart.

 

 

This will be the result

How to Integrate Yahoo Finance API with Matplotlib
How to Integrate Yahoo Finance API with Matplotlib

 

 

Learn More on Python 

Leave a Comment