End-to-end stock analysis pipeline — fetches live market data, computes technical indicators, and predicts closing prices using Linear Regression.
This project is a complete stock market analysis and prediction notebook built for Microsoft Corp (MSFT). It pulls a full year of real historical data directly from Yahoo Finance, computes classic technical indicators used by traders, visualizes market trends, and trains a Linear Regression model to predict future closing prices — all in one clean Jupyter Notebook.
- 📡 Live data fetching — pulls 1 year of OHLCV data for MSFT via
yfinance - 🧹 Data cleaning — drops irrelevant columns, handles missing values
- 📊 Technical indicators — computes 50-day MA, 200-day MA, and RSI (14-day)
- 📉 Trend visualization — plots closing price overlaid with moving averages
- 🤖 Price prediction — Linear Regression model trained on timestamped close prices
- 🎯 Actual vs Predicted — side-by-side plot of real vs model-predicted prices
| Layer | Technology |
|---|---|
| Data Source | yfinance (Yahoo Finance API) |
| Data Handling | Pandas |
| Visualization | Matplotlib, Seaborn |
| ML Model | scikit-learn (Linear Regression) |
| Environment | Jupyter Notebook |
yfinance pulls 1 year of MSFT data
(Open, High, Low, Close, Volume)
│
▼
Data Cleaning
(drop nulls, remove unused columns)
│
▼
Feature Engineering
├── 50-Day Moving Average
├── 200-Day Moving Average
└── RSI — Relative Strength Index (14-day)
│
▼
Visualization
└── Closing Price + MA overlay chart
│
▼
Linear Regression Model
(Date timestamp → Close price)
├── 80/20 Train-Test Split
└── Predict on full dataset
│
▼
Actual vs Predicted Price Plot
| Indicator | What it tells you |
|---|---|
| 50-Day MA | Short-term price trend direction |
| 200-Day MA | Long-term trend; crossover with 50MA signals buy/sell |
| RSI (14-day) | Momentum oscillator — above 70 = overbought, below 30 = oversold |
- Python 3.10+
- Jupyter Notebook or JupyterLab
# 1. Clone the repository
git clone https://github.com/Corerishi/Stock-Market-Analysis-Prediction.git
cd Stock-Market-Analysis-Prediction
# 2. Install dependencies
pip install yfinance pandas matplotlib seaborn scikit-learn jupyter
# 3. Launch Jupyter
jupyter notebook stock_analysis.ipynbNote: The notebook fetches live data on every run — prices will reflect the most recent 1-year window from Yahoo Finance.
Stock-Market-Analysis-Prediction/
├── stock_analysis.ipynb # Main analysis + prediction notebook
├── LICENSE
└── README.md
- Demonstrates a full data science workflow: data ingestion → cleaning → feature engineering → modelling → visualization
- RSI and Moving Average calculations are implemented from scratch using Pandas (no TA libraries)
- Linear Regression is used as a baseline model — a solid starting point before exploring LSTM or ARIMA for time-series forecasting
Rishi Raj
MCA — CHRIST (Deemed to be University)
LinkedIn · GitHub
This project is licensed under the MIT License.