This repository contains the code and data used in the blog post "Data Acquisition: Scraping and Analyzing S&P 500 Stock Performance". The blog post demonstrates how to scrape data from Wikipedia and Yahoo Finance, merge the datasets, and perform basic exploratory data analysis (EDA) on the combined data.
This project explores the question:
"How have S&P 500 companies performed over the past year?"
Data was collected from:
- Wikipedia — for the list of all S&P 500 companies and metadata (sector, symbol, industry, etc.)
- Yahoo Finance — for stock price history and performance metrics
After scraping and merging both datasets, a basic Exploratory Data Analysis was performed to investigate:
- 1-year percentage change by company
- Distribution of returns across sectors
- Top/bottom performing stocks
Ticker- Company ticker symbolCompany- Full company nameSector- Industry sector classificationSubIndustry- More specific industry classification1Y_Change(%)- Percent change in stock price over the past yearVolatility(%)- Annualized volatility of daily returnsAvgAnnualReturn(%)- Average annualized return percentageMaxDrawdown(%)- Maximum decline from peak to trough over the year
scrape.ipynb— Jupyter notebook for scraping and analysissp500_merged.csv— Final merged dataset used in the analysisREADME.md— Project documentation.gitignore— Git ignore file
- Python 3.12
requests,BeautifulSoup4— Web scrapingpandas,numpy— Data cleaning and transformationmatplotlib,seaborn— Data visualization
This project showcases data acquisition techniques and basic EDA on financial data. The findings provide insights into the performance of S&P 500 companies over the past year, highlighting trends and outliers in stock returns.