An end-to-end predictive analytics platform for stock trend forecasting, powered by Machine Learning and LLM-driven financial insights.
Stock Trend Analyzer is a full-stack machine learning application that:
- ๐ Predicts stock price trends using ML forecasting models
- ๐ค Generates AI-powered financial insights using LangChain + OpenAI
- ๐ Visualizes predictions on a real-time interactive dashboard
- ๐ Analyzes historical patterns to surface actionable trading signals
- ๐ก Explains predictions in plain English using LLM-generated commentary
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ DATA SOURCES โ
โ Yahoo Finance API / CSV Historical Data โ
โโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ DATA PIPELINE โ
โ Pandas โข NumPy โข Feature Engineering โข Cleaning โ
โโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโผโโโโโโโโโโโโโ
โผ โผ โผ
โโโโโโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโโโโโ
โ ML Models โ โ SQL DB โ โ LangChain โ
โ (Scikit-learnโ โ(Storage) โ โ + OpenAI LLM โ
โ + PyTorch) โ โ โ โ (Insights) โ
โโโโโโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโโโโโ
โ โ โ
โโโโโโโโโโโโโโผโโโโโโโโโโโโโ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ STREAMLIT DASHBOARD โ
โ Real-time Charts โข Predictions โข AI Commentary โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
| Category | Technology |
|---|---|
| Language | Python 3.10+ |
| ML Models | Scikit-learn, PyTorch, LSTM |
| LLM / AI | LangChain, OpenAI GPT-4 |
| Data Processing | Pandas, NumPy, SciPy |
| Visualization | Streamlit, Matplotlib, Plotly |
| Database | SQL (SQLite / PostgreSQL) |
| Data Source | Yahoo Finance API (yfinance) |
| DevOps | Git, Docker |
- ๐ Multi-model forecasting โ LSTM, Random Forest, Linear Regression
- ๐ค LLM-powered commentary โ AI explains predictions in plain English
- ๐ Interactive dashboard โ real-time Streamlit charts with zoom/filter
- ๐ Technical indicators โ RSI, MACD, Bollinger Bands, Moving Averages
- ๐ Anomaly detection โ flags unusual price movements automatically
- ๐พ Historical backtesting โ evaluate model accuracy on past data
- โก Fast predictions โ sub-second inference on trained models
- ๐ฏ Multi-stock support โ analyze any ticker (AAPL, TSLA, GOOGL, etc.)
Python 3.10+
OpenAI API Key (for LLM insights)# Clone the repository
git clone https://github.com/jeevan1098/Stock-Trend-Analyzer
cd Stock-Trend-Analyzer
# Create virtual environment
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Set environment variables
cp .env.example .env
# Add OPENAI_API_KEY to .env# Launch Streamlit dashboard
streamlit run app.py
# App opens at http://localhost:8501import yfinance as yf
# Fetch historical stock data
stock = yf.Ticker("AAPL")
df = stock.history(period="2y")# Technical indicators
df['RSI'] = compute_rsi(df['Close'], window=14)
df['MACD'] = compute_macd(df['Close'])
df['BB_upper'], df['BB_lower'] = compute_bollinger(df['Close'])
df['MA_50'] = df['Close'].rolling(50).mean()
df['MA_200'] = df['Close'].rolling(200).mean()from sklearn.ensemble import RandomForestRegressor
model = RandomForestRegressor(n_estimators=100)
model.fit(X_train, y_train)
predictions = model.predict(X_test)from langchain.chains import LLMChain
# Generate plain English explanation of prediction
insight = chain.run(
ticker="AAPL",
prediction=predictions[-1],
trend="upward",
confidence=0.87
)
# Output: "Apple stock shows strong bullish momentum..."| Model | MAE | RMSE | Rยฒ Score |
|---|---|---|---|
| LSTM Neural Network | 2.34 | 3.12 | 0.91 |
| Random Forest | 2.87 | 3.76 | 0.88 |
| Linear Regression | 4.21 | 5.43 | 0.79 |
| Ensemble (Best) | 1.98 | 2.67 | 0.93 |
Stock-Trend-Analyzer/
โ
โโโ app.py # Streamlit dashboard entry point
โโโ requirements.txt # Python dependencies
โโโ .env.example # Environment variables template
โ
โโโ data/
โ โโโ fetch_data.py # Yahoo Finance data ingestion
โ โโโ preprocess.py # Data cleaning + feature engineering
โ โโโ indicators.py # Technical indicators (RSI, MACD, BB)
โ
โโโ models/
โ โโโ lstm_model.py # LSTM neural network
โ โโโ random_forest.py # Random Forest regressor
โ โโโ ensemble.py # Ensemble model combiner
โ โโโ evaluate.py # Model evaluation metrics
โ
โโโ llm/
โ โโโ langchain_agent.py # LangChain + OpenAI integration
โ โโโ insight_generator.py # LLM financial commentary
โ
โโโ dashboard/
โ โโโ charts.py # Plotly/Matplotlib visualizations
โ โโโ components.py # Streamlit UI components
โ
โโโ tests/
โโโ test_models.py # Model accuracy tests
โโโ test_pipeline.py # Data pipeline tests
- ๐ Individual investors โ get AI-powered stock analysis instantly
- ๐ฆ Financial analysts โ automate trend reporting with LLM commentary
- ๐ ML researchers โ benchmark forecasting models on financial data
- ๐ Students โ learn applied ML + LLM integration on real-world data
- Add sentiment analysis from financial news (Reuters, Bloomberg)
- Real-time streaming data with Apache Kafka
- Portfolio optimization using Modern Portfolio Theory
- Options pricing with Black-Scholes model
- Deploy on AWS Lambda for serverless predictions
Jeevan Babu Gotru
โญ Star this repo if you found it useful!
Built with โค๏ธ | MS Computer Science @ University of South Alabama