An AI-powered stock price prediction platform that leverages multiple machine learning models to provide comprehensive market analysis and predictions.
- Linear Regression - Simple trend analysis with bar charts
- Random Forest - Ensemble learning with line charts
- XGBoost - Gradient boosting with area charts
- LSTM (Deep Learning) - Neural network-based predictions with candlestick-style charts
- Live stock data fetching from Yahoo Finance
- Support for global markets (US, India, UK, Japan, Europe, etc.)
- Automatic currency detection and display (USD $, INR โน, GBP ยฃ, EUR โฌ, JPY ยฅ)
- News scraping for stock-related articles
- Sentiment analysis using NLP
- Integration of sentiment data with price predictions
- Clean, card-based UI with 2x2 grid layout
- Multiple chart types for different models
- Real-time prediction updates
- Responsive design
StockSense AI/
โโโ app/
โ โโโ backend/ # Flask REST API
โ โ โโโ routes/ # API endpoints
โ โ โโโ utils/ # Model runners
โ โโโ frontend/ # React + Vite
โ โโโ src/
โ โโโ components/
โ โโโ pages/
โ โโโ api/
โโโ data/ # Data processing
โโโ models/ # ML model training
โโโ sentiment/ # News & sentiment analysis
โโโ portfolio/ # Portfolio simulation
โโโ risk/ # Risk analysis tools
- Python 3.10+
- Node.js 16+
- npm or yarn
- Clone the repository
git clone https://github.com/Kush05Bhardwaj/Stocksense-AI.git
cd "StockSense AI"- Set up Python environment
python -m venv venv
.\venv\Scripts\activate # On Windows
source venv/bin/activate # On Mac/Linux
pip install -r requirements.txt- Set up Frontend
cd app/frontend
npm install- Start the Backend Server
# From project root
.\venv\Scripts\activate
python app/backend/app.pyBackend runs on: http://localhost:5000
- Start the Frontend
cd app/frontend
npm startFrontend runs on: http://localhost:3000
- Access the Application
Open your browser and navigate to:
http://localhost:3000
-
Enter a stock symbol in the search box:
- US Stocks:
AAPL,MSFT,GOOGL,TSLA - Indian Stocks:
RELIANCE.NS,TCS.NS,INFY.NS - Japanese Stocks:
7203.T(Toyota),9984.T(SoftBank) - UK Stocks:
BP.L,HSBA.L
- US Stocks:
-
Click "Predict" to get predictions from all 4 models
-
View results in the card layout:
- Current price
- Predicted prices from each model
- Expected change percentage
- Visual charts for each prediction
For training custom models:
# 1. Fetch stock data
python data/fetch_data.py
# 2. Scrape news
python sentiment/news_scraper.py
# 3. Analyze sentiment
python sentiment/sentiment_analyzer.py
# 4. Merge data
python sentiment/merge_sentiment.py
# 5. Compare models
python models/compare_models.py
# 6. Train LSTM
python models/lstm_model.py- Flask - Web framework
- yFinance - Stock data API
- pandas - Data manipulation
- scikit-learn - ML models (Linear Regression, Random Forest)
- XGBoost - Gradient boosting
- TensorFlow/Keras - Deep learning (LSTM)
- TextBlob - Sentiment analysis
- NewsAPI - News data
- React 18 - UI framework
- Vite - Build tool and dev server
- Axios - HTTP client
- Recharts - Data visualization
- CSS3 - Styling
- NumPy - Numerical computing
- Matplotlib/Seaborn - Data visualization
- BeautifulSoup4 - Web scraping
StockSense AI/
โ
โโโ app/
โ โโโ backend/
โ โ โโโ app.py # Flask application entry point
โ โ โโโ routes/
โ โ โ โโโ predict.py # Prediction endpoints
โ โ โ โโโ portfolio.py # Portfolio management
โ โ โ โโโ sentiment.py # Sentiment analysis
โ โ โโโ utils/
โ โ โโโ model_runner.py # ML model execution
โ โ โโโ risk_runner.py # Risk calculations
โ โ
โ โโโ frontend/
โ โโโ src/
โ โ โโโ components/
โ โ โ โโโ StockSearch.jsx # Main search component
โ โ โ โโโ PredictionCard.jsx
โ โ โโโ pages/
โ โ โ โโโ Dashboard.jsx # Main dashboard
โ โ โ โโโ Portfolio.jsx # Portfolio view
โ โ โโโ api/
โ โ โ โโโ api.js # API integration
โ โ โโโ App.jsx # Root component
โ โ โโโ main.jsx # Entry point
โ โโโ index.html
โ โโโ vite.config.js
โ โโโ package.json
โ
โโโ data/
โ โโโ fetch_data.py # Stock data fetching
โ โโโ visualize.py # Data visualization
โ โโโ raw/ # Raw data storage
โ โโโ processed/ # Processed data
โ โโโ visualizations/ # Charts and graphs
โ
โโโ models/
โ โโโ prepare_data.py # Feature engineering
โ โโโ linear_model.py # Linear Regression
โ โโโ rf_model.py # Random Forest
โ โโโ xgb_model.py # XGBoost
โ โโโ lstm_model.py # LSTM Neural Network
โ โโโ compare_models.py # Model comparison
โ
โโโ sentiment/
โ โโโ news_scraper.py # News article scraping
โ โโโ sentiment_analyzer.py # Sentiment analysis
โ โโโ merge_sentiment.py # Data integration
โ
โโโ portfolio/
โ โโโ simulator.py # Portfolio simulation
โ
โโโ risk/
โ โโโ volatility.py # Volatility calculations
โ โโโ confidence.py # Confidence intervals
โ
โโโ requirements.txt # Python dependencies
โโโ .gitignore # Git ignore rules
โโโ README.md # This file
POST /api/predict
Content-Type: application/json
{
"symbol": "AAPL"
}
Response:
{
"symbol": "AAPL",
"company_name": "Apple Inc.",
"current_price": 230.45,
"currency": "$",
"predictions": [
{
"model": "Linear Regression",
"prediction": 232.10,
"change": 0.72
},
...
]
}Edit app/backend/app.py:
- Port: Default
5000 - Debug mode:
Truefor development
Edit app/frontend/vite.config.js:
- Port: Default
3000 - Proxy: Routes
/api/*to backend
Based on AAPL stock data (2020-2026):
| Model | MAE | RMSE | Type |
|---|---|---|---|
| Linear Regression | 2.5 | 3.1 | Simple |
| Random Forest | 1.8 | 2.4 | Ensemble |
| XGBoost | 1.6 | 2.1 | Gradient Boosting |
| LSTM | 1.4 | 1.9 | Deep Learning |
Lower values indicate better performance
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Flask - Web framework by Pallets
- React - UI library by Meta
- Vite - Build tool by Evan You
- scikit-learn - Machine learning library
- XGBoost - Gradient boosting framework
- TensorFlow - Deep learning framework by Google
- Keras - High-level neural networks API
- pandas - Data analysis library
- NumPy - Numerical computing library
- yFinance - Yahoo Finance API wrapper
- Recharts - Charting library for React
- Axios - HTTP client
- TextBlob - Natural language processing
- BeautifulSoup4 - Web scraping
- Matplotlib - Plotting library
- Seaborn - Statistical visualization
- Yahoo Finance - Stock market data
- NewsAPI - News articles and headlines
- Financial machine learning research papers
- Kaggle stock prediction competitions
- Time series forecasting methodologies
- Sentiment analysis in financial markets
- The open-source community for amazing tools and libraries
- Contributors and testers
- Stack Overflow community for troubleshooting help
Kushagra Bhardwaj
- GitHub: @Kush05Bhardwaj
- Repository: Stocksense-AI
For support, questions, or feedback:
- Open an issue on GitHub
- Real-time WebSocket updates
- Advanced portfolio optimization
- Technical indicators (RSI, MACD, etc.)
- Multi-timeframe analysis
- User authentication and saved portfolios
- Email alerts for price targets
- Mobile app (React Native)
- Cryptocurrency support
- Options pricing models
This application is for educational and informational purposes only. It is not financial advice.
- Stock predictions are based on historical data and machine learning models
- Past performance does not guarantee future results
- Always do your own research before making investment decisions
- Consult with a qualified financial advisor for investment advice
- The developers are not responsible for any financial losses
If you find this project helpful, please give it a โญ on GitHub!