This Streamlit application is designed to provide insights into the S&P 500 stock market, including visualizing the closing prices and volumes of S&P 500 stocks. Additionally, it retrieves and displays a list of S&P 500 companies categorized by their sectors. Users can interact with the app to filter companies based on sectors and download relevant data.
- Stock Data Visualization: Showcases line charts for the closing prices and volumes of S&P 500 stocks over a specified period.
- Historical Data Table: Displays a table with historical data of the S&P 500 index, including Open, High, Low, Close, and Volume.
- Sector-based Company Filtering: Allows users to select one or multiple sectors to filter companies and view their details.
- Data Download: Provides an option to download the filtered list of companies as a CSV file.
- Interactive Plots: Users can select the number of companies to visualize their stock closing prices through interactive plots.
- Python Libraries: Utilizes
streamlit
,pandas
,matplotlib
,yfinance
, andbase64
for web app development, data manipulation, visualization, financial data retrieval, and encoding, respectively. - Data Sources:
- Historical stock data is fetched using the
yfinance
library. - The list of S&P 500 companies is scraped from Wikipedia.
- Historical stock data is fetched using the
- User Inputs: Through the sidebar, users can select sectors to filter companies and adjust the number of companies for which they want to visualize stock data.
- Launch the App: Run the Streamlit application to start interacting with the features.
- View Stock Charts: By default, the app displays line charts for the closing prices and volumes of the S&P 500 index.
- Filter Companies by Sector: Use the sidebar to select sectors and view companies belonging to those sectors.
- Download Data: Click on the provided link to download the filtered list of companies as a CSV file.
- Visualize Company Stocks: Adjust the slider to select the number of companies, and click 'Show Plots' to visualize their stock closing prices.
To run the app, ensure you have Streamlit and other required libraries installed in your environment. Use the command streamlit run your_script.py
to start the app, replacing your_script.py
with the path to your script file.
This Streamlit application offers an interactive platform for analyzing S&P 500 stocks, providing valuable insights into stock performances and market trends. Through its intuitive interface, users can easily navigate through different features, making stock analysis accessible to both experts and novices in the field of finance.