| # S&P 500 Stock Data - Exploratory Data Analysis | |
| ## Overview | |
| This project presents an exploratory data analysis (EDA) of daily stock data for S&P 500 companies. | |
| The analysis focuses on sector composition, volatility patterns, and the relationship between risk and return in the S&P 500 universe. | |
| ## Dataset Description | |
| The analysis combines two public datasets: | |
| - **Price Data:** Daily prices (open, high, low, close, volume, symbol) for S&P 500 companies, covering a 5-year period (~620,000 rows). | |
| - **Constituents Data:** Sector information for each company, based on the latest S&P 500 constituents list. | |
| The datasets were merged by stock symbol so that each row contains both price history and sector. | |
| ## Main Research Questions | |
| 1. **What percentage of S&P 500 stocks belong to each sector?** | |
| 2. **Which sector in the S&P 500 is the most volatile?** | |
| 3. **Within the most volatile sector, which stocks are the most volatile?** | |
| 4. **Is there a relationship between risk (volatility) and average return for S&P 500 stocks?** | |
| --- | |
| ## Data Cleaning & Preparation | |
| - Checked and removed duplicate rows. | |
| - Excluded records with missing or invalid dates, closing prices, or stock symbols. | |
| - Converted date fields to datetime for accurate time series analysis. | |
| - Sorted entries by stock and date. | |
| - Merged sector information from the constituents dataset. | |
| - Calculated daily returns and stock volatility (standard deviation of daily returns). | |
| --- | |
| ## Exploratory Analysis & Key Insights | |
| ### 1. Sector Composition | |
| The pie chart shows that Information Technology, Health Care, and Financials are the largest sectors by number of companies, while sectors like Utilities and Materials are less represented in the S&P 500. | |
|  | |
| --- | |
| ### 2. Sector Volatility | |
| The bar chart reveals that the Energy sector has the highest average volatility among all sectors, indicating that Energy stocks experience the largest daily price fluctuations. | |
|  | |
| --- | |
| ### 3. Most Volatile Stocks in the Most Volatile Sector | |
| The ranking plot shows that in the Energy sector, **WMB (Williams Companies)** is the most volatile stock, with a volatility level noticeably higher than all others. **DVN** and **OKE** follow, but with lower volatility. The difference between WMB and the rest is especially significant. | |
|  | |
| --- | |
| ### 4. Risk vs. Return | |
| The scatter plot with regression line suggests a weak positive relationship between risk and return: stocks with higher volatility tend to have slightly higher average daily returns, but the overall trend is not strong. | |
|  | |
| --- | |
| ## Outlier Handling | |
| Outliers in daily returns were identified using the IQR method. Since these outliers represent actual market events and not errors, they were retained in the analysis. | |
| --- | |
| ## Limitations | |
| - Sectoral shares were based on company counts rather than market capitalization, as Market Cap was not available. | |
| - The analysis did not include dividends, macroeconomic events, or company fundamentals. | |
| - Results are based on historical price and volume data only. | |
| --- | |
| ## Conclusion | |
| The EDA uncovers important patterns in sector distribution, volatility, and the risk-return relationship across the S&P 500. It highlights both broad trends and unique behaviors within specific sectors and stocks. | |
| --- | |
| ## Video Presentation | |
| *A link to a short video presentation summarizing these findings will be added here.* | |
| --- | |
| ## Files | |
| - `all_stocks_5yr.csv` – Stock price data | |
| - `constituents.csv` – Sector/company info | |
| - `sp500_eda.ipynb` – Full analysis notebook | |
| - `README.md` – This summary | |
| --- | |
| *For further details, see the code and visualizations in the attached notebook.* |