Python is a great language for making data-based analysis and visualizations. It also helps that there is a wide range of open-source libraries that can be used off the shelf for some great functionalities.
In this article, we will be learning to build a Stock data dashboard using Python Dash, Pandas and Yahoo’s Finance API.
Install the latest version of Pandas Datareader
pip install pandas_datareader
Install the latest version of Dash
pip install dash
Import all the required libraries
Now let’s make a user interface using dash. We are going to make a simple yet functional user interface, one will be a simple Heading title and a input textbox for the user to type in the stock names.
The input text box is now just a static text box. To get the input data, which in this case is the stock name of a company, from the user interface, we should add app callbacks. The read stock name(input_data) is passed as a parameter to the method update_value. The function then gets all the stock data from the Yahoo Finance API since 1st January 2010 till now, the current day and is store in a Pandas data frame. A graph is plotted, with the X-axis being the index of the data frame, which is time in years, Y-axis with the closing stock price of each day and the name of the graph being the stock name(input_data). This graph is returned to the callback wrapper which then displays it on the user interface.
Code: Finally, run the server.
The web application will now run on the local host at 8050 by default.
Let’s consider an example. The stock name of Google is GOOGL. Let’s enter this data into the input text box.
Below is the result.
- Python Bokeh – Visualizing Stock Data
- Data Visualisation with Chartify
- 3D Visualisation of Insertion Sort using Matplotlib in Python
- Python | Plotting Stock charts in excel sheet using XlsxWriter module
- Tableau - Change the order in visualisation
- Python - Convert Tick-by-Tick data into OHLC (Open-High-Low-Close) Data
- Python for Data Science
- Exporting PDF Data using Python
- Python Data Types
- Python | Data Augmentation
- Python IDEs For Data Science
- Data visualization with different Charts in Python
- Data analysis and Visualization with Python
- Python | Data analysis using Pandas
- Python - Data visualization using Bokeh
- Working With JSON Data in Python
- Top 8 Python Libraries for Data Visualization
- How to Scrape Web Data from Google using Python?
- Working with Binary Data in Python
- 10 Reasons Why You Should Choose Python For Big Data