This project analyzes and visualizes stock data for SPY (S&P 500 ETF) and GOOG (Google/Alphabet) using Python. It demonstrates various data analysis techniques and visualization methods using popular libraries such as pandas, numpy, matplotlib, and seaborn.
- Fetches historical stock data using yfinance
- Calculates logarithmic returns
- Computes correlation matrix between stocks
- Performs linear regression analysis
- Visualizes stock price trends and scatter plots
- numpy
- pandas
- pandas_datareader
- matplotlib
- seaborn
- yfinance
- Install the required dependencies:
- Run the script to generate visualizations and analysis:
The script generates several visualizations:
- Scatter plot of SPY vs GOOG returns with a linear regression line
- Time series plot of SPY (S&P 500) closing prices with a trend line
- Seaborn regression plot for the last 63 days of SPY data
The script performs the following analyses:
- Calculates correlation matrix between SPY and GOOG returns
- Fits a linear regression model to the sampled data
- Predicts future stock prices based on the regression model
Feel free to fork this repository and submit pull requests with improvements or additional features.
This project is open-source and available under the MIT License.