

Engineered a financial data analytics web application that applies algorithmic modeling to historical equity data to project future market trends and price movements.
AI-Powered Indian Stock Market Forecasting Platform
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.
| Feature | Description |
|---|---|
| ๐ค Adaptive ML Engine | Self-improving prediction models with accuracy tracking across algorithm versions |
| ๐ฐ News Sentiment Analysis | Scores news headlines as positive / negative / neutral to influence predictions |
| ๐ Gemini AI Integration | Google Gemini AI powers advanced stock analysis and insights |
| ๐ Smart Alerts System | Real-time BUY / SELL / HIGH RISK / BULLISH alerts with email notifications |
| ๐ค User Auth + OTP | Secure registration, login, and password reset via email OTP |
| ๐ Watchlist | Per-user watchlists with per-stock notification preferences |
| ๐ก๏ธ Admin Dashboard | Manage stocks, users, email config, and model training from one panel |
| ๐ Technical Indicators | SMA, EMA, RSI, MACD computed and stored for every stock |
| ๐ฎ๐ณ Indian Market Focus | Pre-loaded with TCS, Reliance, HDFC Bank, Infosys, Wipro, SBI & more |
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
The app uses Flask-SQLAlchemy with these core models:
| Model | Purpose |
|---|---|
User | Auth, roles (admin/user), email notifications |
Stock | NSE/BSE symbols, sectors, model version tracking |
HistoricalData | OHLCV + SMA, EMA, RSI, MACD per stock per day |
Prediction | ML predictions with confidence, trend, recommendation |
NewsSentiment | Headline sentiment scores linked to stocks |
Watchlist / UserWatchlist | Per-user stock tracking with notification toggle |
StockAlert | System-generated BUY/SELL/HIGH RISK alerts |
Notification | User notification history |
ModelTraining | Training logs โ accuracy, MAE, RMSE per version |
OTP | Email OTP for registration and password reset |
EmailConfig | Admin-configurable SMTP settings |
MarketStatus | NSE market open/close calendar |
bashgit clone https://github.com/ganesha-raut/StockMarketPrediction.git cd StockMarketPrediction
bashpython -m venv venv # macOS / Linux source venv/bin/activate # Windows venv\Scripts\activate
bashpip install -r requirements.txt
Edit config.py and set:
pythonSECRET_KEY = 'your-secret-key' GEMINI_API_KEY = 'your-gemini-api-key' # optional MAIL_USERNAME = 'your@gmail.com' MAIL_PASSWORD = 'your-app-password'
bashpython run.py
๐ข App live at
http://127.0.0.1:5000
๐ Default admin:admin@stockai.com/admin123(change immediately!)
bashpython run_adaptive_monitor.py
Runs the background ML monitoring service that re-evaluates prediction accuracy and retrains models automatically.
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
| Method | Route | Description |
|---|---|---|
GET | / | Landing page / redirect |
GET | /health | Health check |
POST | /auth/login | Login |
POST | /auth/register | Register with OTP |
GET | /user/home | User dashboard |
GET | /admin/dashboard | Admin panel |
GET | /api/... | JSON data for charts & predictions |
| Alert | Severity | Trigger |
|---|---|---|
BULLISH_OPPORTUNITY | ๐ข opportunity | Strong upward prediction |
HIGH_RISK | ๐ด critical | High predicted downside |
TARGET_REACHED | ๐ต info | User's target price hit |
DROP_ALERT | ๐ก warning | Price drop exceeds threshold |
git checkout -b feature/amazing-featuregit commit -m 'Add amazing feature'git push origin feature/amazing-featureThis project is open-source under the MIT License.
Made with โค๏ธ by Ganesha Raut
โญ Star this repo if you found it useful! โญ