Sector Area Chart
Display an area chart representing the weight of different industry sectors over time
In this cookbook, we'll walk through the process of creating a simple dashboard that plots a time series area chart for industry sectors using Finter, a quantitative finance library, and Gradio, a Python library for creating customizable UI components for machine learning models.
Prerequisites
Before you begin, ensure you have the following installed:
Python 3.6 or later
finter
librarygradio
librarypandas
libraryplotly
librarypython-dotenv
library
You can install these with pip:
Step 1: Load Environment Variables
First, we need to load environment variables from a .env
file. This is where you would store sensitive information such as API keys.
Step 2: Define Constants and Functions
Set the end date for the data you want to retrieve. In this example, we're using 20240401
as the end date.
Define a function to plot the sector area chart. This function takes a model_name
as input, loads the model data, and creates a chart.
Step 3: Create the Gradio Interface
Set up the Gradio interface with an input textbox for the model name and a button to plot the chart. The chart will be displayed as output.
Expected Output
When you run the script, it will launch a web server and open a browser window with the Gradio interface. You can enter a model name into the textbox and click "Plot Chart" to generate the area chart. The chart will display the time series data for industry sectors, with each sector represented by a different color.
Conclusion
You've now created a simple dashboard that visualizes sector weights over time using Finter and Gradio. This dashboard can be easily modified to include additional features or to work with different datasets.
Last updated