TrendPulse - Machine Learning Stock Market Prediction System
TrendPulse - Machine Learning Stock Market Prediction System
Featured Project
AI/ML

TrendPulse - Machine Learning Stock Market Prediction System

Engineered a financial data analytics web application that applies algorithmic modeling to historical equity data to project future market trends and price movements.

PythonTensorFlowSkritLearningHTMLCSSJavaScript
README.md
Markdown

๐Ÿ“ˆ StockMarketPrediction

AI-Powered Indian Stock Market Forecasting Platform

Python Flask SQLAlchemy Gemini AI License

A full-stack web application that predicts NSE/BSE stock prices using adaptive Machine Learning,
news sentiment analysis, and Gemini AI โ€” with real-time alerts, user watchlists, and an admin dashboard.

โœจ Key Features

FeatureDescription
๐Ÿค– Adaptive ML EngineSelf-improving prediction models with accuracy tracking across algorithm versions
๐Ÿ“ฐ News Sentiment AnalysisScores news headlines as positive / negative / neutral to influence predictions
๐Ÿ’Ž Gemini AI IntegrationGoogle Gemini AI powers advanced stock analysis and insights
๐Ÿ”” Smart Alerts SystemReal-time BUY / SELL / HIGH RISK / BULLISH alerts with email notifications
๐Ÿ‘ค User Auth + OTPSecure registration, login, and password reset via email OTP
๐Ÿ“‹ WatchlistPer-user watchlists with per-stock notification preferences
๐Ÿ›ก๏ธ Admin DashboardManage stocks, users, email config, and model training from one panel
๐Ÿ“Š Technical IndicatorsSMA, EMA, RSI, MACD computed and stored for every stock
๐Ÿ‡ฎ๐Ÿ‡ณ Indian Market FocusPre-loaded with TCS, Reliance, HDFC Bank, Infosys, Wipro, SBI & more

๐Ÿ—๏ธ Project Structure

StockMarketPrediction/ โ”‚ โ”œโ”€โ”€ app.py # Application factory โ€” wires everything together โ”œโ”€โ”€ run.py # Entry point to start the server โ”œโ”€โ”€ run_adaptive_monitor.py # Background adaptive ML monitoring service โ”œโ”€โ”€ models.py # SQLAlchemy DB models (User, Stock, Prediction, Alert...) โ”œโ”€โ”€ config.py # App configuration (dev / prod) โ”œโ”€โ”€ configure_email.py # Email setup utility โ”œโ”€โ”€ requirements.txt # Python dependencies โ”‚ โ”œโ”€โ”€ routes/ # Flask Blueprints โ”‚ โ”œโ”€โ”€ auth.py # /auth โ€” Login, register, OTP, password reset โ”‚ โ”œโ”€โ”€ user.py # /user โ€” Home, watchlist, notifications โ”‚ โ”œโ”€โ”€ admin.py # /admin โ€” Dashboard, stock & user management โ”‚ โ””โ”€โ”€ api.py # /api โ€” JSON endpoints for charts & predictions โ”‚ โ”œโ”€โ”€ services/ # Business logic layer โ”‚ โ”œโ”€โ”€ ml_models/ โ”‚ โ””โ”€โ”€ adaptive/ # Adaptive self-improving ML models โ”‚ โ”œโ”€โ”€ utils/ โ”‚ โ”œโ”€โ”€ email_service.py # Flask-Mail wrapper โ”‚ โ”œโ”€โ”€ gemini_ai.py # Google Gemini AI client โ”‚ โ””โ”€โ”€ scheduler.py # Background job scheduler โ”‚ โ”œโ”€โ”€ templates/ # Jinja2 HTML templates โ”‚ โ””โ”€โ”€ errors/ # 404 / 500 error pages โ”‚ โ”œโ”€โ”€ static/ # CSS, JS, images โ”œโ”€โ”€ data/ # Raw & processed stock data โ”œโ”€โ”€ uploads/ # User-uploaded files โ””โ”€โ”€ .gitignore

๐Ÿ—„๏ธ Database Models

The app uses Flask-SQLAlchemy with these core models:

ModelPurpose
UserAuth, roles (admin/user), email notifications
StockNSE/BSE symbols, sectors, model version tracking
HistoricalDataOHLCV + SMA, EMA, RSI, MACD per stock per day
PredictionML predictions with confidence, trend, recommendation
NewsSentimentHeadline sentiment scores linked to stocks
Watchlist / UserWatchlistPer-user stock tracking with notification toggle
StockAlertSystem-generated BUY/SELL/HIGH RISK alerts
NotificationUser notification history
ModelTrainingTraining logs โ€” accuracy, MAE, RMSE per version
OTPEmail OTP for registration and password reset
EmailConfigAdmin-configurable SMTP settings
MarketStatusNSE market open/close calendar

โšก Getting Started

Prerequisites

  • Python 3.10+
  • pip
  • A Gmail (or SMTP) account for email features
  • Google Gemini API key (optional but recommended)

1 ยท Clone the Repository

bash
git clone https://github.com/ganesha-raut/StockMarketPrediction.git cd StockMarketPrediction

2 ยท Create Virtual Environment

bash
python -m venv venv # macOS / Linux source venv/bin/activate # Windows venv\Scripts\activate

3 ยท Install Dependencies

bash
pip install -r requirements.txt

4 ยท Configure the App

Edit config.py and set:

python
SECRET_KEY = 'your-secret-key' GEMINI_API_KEY = 'your-gemini-api-key' # optional MAIL_USERNAME = 'your@gmail.com' MAIL_PASSWORD = 'your-app-password'

5 ยท Run the Server

bash
python run.py

๐ŸŸข App live at http://127.0.0.1:5000
๐Ÿ”‘ Default admin: admin@stockai.com / admin123 (change immediately!)

6 ยท Start the Adaptive Monitor (optional)

bash
python run_adaptive_monitor.py

Runs the background ML monitoring service that re-evaluates prediction accuracy and retrains models automatically.

๐Ÿค– Machine Learning Pipeline

Raw yfinance Data โ”‚ โ–ผ Feature Engineering (SMA, EMA, RSI, MACD, Volume, Sentiment Score) โ”‚ โ–ผ Adaptive ML Models โ”€โ”€โ–บ Accuracy Tracker (ml_models/adaptive/) โ”‚ โ”‚ Auto-retrain if โ–ผ accuracy drops Prediction + Confidence (trend: bullish / bearish / neutral) โ”‚ โ–ผ Recommendation: BUY / SELL / HOLD + Smart Alerts

Pre-loaded Indian Stocks: TCS ยท RELIANCE ยท HDFCBANK ยท INFY ยท ICICIBANK ยท HINDUNILVR ยท ITC ยท SBIN ยท BHARTIARTL ยท WIPRO

๐Ÿ›ฃ๏ธ API Endpoints

MethodRouteDescription
GET/Landing page / redirect
GET/healthHealth check
POST/auth/loginLogin
POST/auth/registerRegister with OTP
GET/user/homeUser dashboard
GET/admin/dashboardAdmin panel
GET/api/...JSON data for charts & predictions

๐Ÿ”” Alert Types

AlertSeverityTrigger
BULLISH_OPPORTUNITY๐ŸŸข opportunityStrong upward prediction
HIGH_RISK๐Ÿ”ด criticalHigh predicted downside
TARGET_REACHED๐Ÿ”ต infoUser's target price hit
DROP_ALERT๐ŸŸก warningPrice drop exceeds threshold

๐Ÿค Contributing

  1. Fork the repo
  2. Create your feature branch: git checkout -b feature/amazing-feature
  3. Commit your changes: git commit -m 'Add amazing feature'
  4. Push to the branch: git push origin feature/amazing-feature
  5. Open a Pull Request

๐Ÿ“„ License

This project is open-source under the MIT License.

Made with โค๏ธ by Ganesha Raut

โญ Star this repo if you found it useful! โญ

Project Stats

11Views
Popularity100%

Features

  • ๐Ÿ“ˆ Algorithmic Trend Forecasting
  • ๐Ÿ“Š Interactive Dark Charts
  • ๐Ÿ“‰ Historical Data Analysis
  • โšก Real-Time API Extraction