Hello Everyone ! In this tutorial I will be showing you, how to plot Financial stock market data using Bokeh library and Pandas Data reader  in python.The modules that we are going to use for this tutorial are pandas,pandas data reader and bokeh. So in case you have not installed these packages, please type the below line in your windows prompt.

pip install pandas pandas-datareader bokeh

Now since the libraries are installed lets import these packages in our program app.py like this

import pandas as pd
import pandas_datareader as pdr
from bokeh.plotting import figure,show,output_file
from datetime import datetime

Our libraries have been imported and now we can start using them in our program. Please note that this program uses the Yahoo API and we monitors the data for the company  APPLE(you are free to play with these parameters).


Now that our data has been fetched we can proceed with some pre-processing with it to depict the visuals in an attractive and serialized manner.

date_time=[datetime.strptime(str(d),'%Y-%m-%d %H:%M:%S').date() for d in date_list]

At this point we are done with our data pre-processing and now we can take one step to the podium and plot our bokeh graph.

p=figure(x_axis_type='datetime',plot_width=800,plot_height=500,title="Financial Analysis of Apple",tools="",
p.circle(date_time,open_list,legend="Open Price",size=6,color="green", alpha=0.5)
p.line(date_time,open_list,legend="Open Price",color="green", alpha=0.5)
p.circle(date_time,close_list,legend="Close Price",size=6,color="red", alpha=0.5)
p.line(date_time,close_list,legend="Close Price",color="red", alpha=0.5)
p.legend.location = "bottom_right"

We are done over here and we can now run this program using the command python app.py in our command prompt.To view the result please open the generated .html file in the browser. Enjoy !