This project provides a simple yet extensible framework for predicting future stock prices based on historical data. The goal is to give developers, dataโscientists and hobbyists a starting point for experimenting with different machineโlearning and deepโlearning approaches to time series forecasting.
- Modern UI : Beautiful, responsive web interface
- Interactive Charts : Zoom, hover, and pan capabilities
- Real-time Analysis : Instant results with live data
- Multiple Models : Compare Linear Regression vs Random Forest
- RSI : Relative Strength Index for overbought/oversold signals
- MACD : Moving Average Convergence Divergence
- Bollinger Bands : Volatility and trend analysis
- Moving Averages : SMA and EMA for trend identification
- Volume Analysis : Volume-based indicators
- Feature Engineering : 19+ technical indicators
- Model Comparison : Performance metrics (MSE, RMSE, MAE, Rยฒ)
- Feature Importance : Understand what drives predictions
- Forecast Visualization : See predictions on interactive charts
- Price Threshold Alerts : Set notifications for specific price levels
- Real-time Monitoring : Alerts trigger during stock analysis
- Easy Management : Add, edit, and delete alerts with simple interface
- Main Analysis : Multi-stock prediction and comparison
- Comparison Tool : Side-by-side stock analysis
- Market Overview : Real-time market data and indices
- Alerts Management : Configure price notifications
- Documentation : Complete user guide and help
StockPricePredictor/
โโโ App.py # Main Streamlit application
โโโ main.py # Original CLI version
โโโ pages/ # Streamlit multipage app
โ โโโ 2_Comparison_Tool.py
โ โโโ 3_Market_Overview.py
โ โโโ 4_Alertes.py
โ โโโ 5_Documentation.py
โโโ requirements.txt # Dependencies
โโโ alerts_config.json # Alerts configuration
โโโ README.md # This file
Launch the main application:
streamlit run App.pyThen open your browser to: http://localhost:8501
python main.py --ticker AAPL --start 2023-01-01 --end 2024-01-01 --model random_forest --forecast_horizon 7- Clone the repository:
git clone <repository-url>
cd StockPricePredictor- Create virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txtMain App:
- Select Stocks : Choose multiple tickers (AAPL, MSFT, TSLA, etc.)
- Set Date Range : Pick start and end dates
- Choose Model : Linear Regression or Random Forest
- Set Forecast Days : 1-30 days into the future
- Click "Analyze Stocks" : Get instant results!
Additional Pages:
- ๐ Comparison Tool : Compare multiple stocks side-by-side
- ๐ Market Overview : Real-time market data and indices
- ๐ Alerts : Set price threshold notifications
- ๐ Documentation : Complete guide and help
# Basic usage
python main.py --ticker AAPL
# Advanced usage
python main.py --ticker TSLA --start 2023-01-01 --end 2024-01-01 --model random_forest --forecast_horizon 10 --no_plots
# Compare different stocks
python main.py --ticker MSFT --start 2022-01-01 --end 2024-01-01 --model linear --forecast_horizon 5- SMA (Simple Moving Average) : 5, 10, 20-day averages
- EMA (Exponential Moving Average) : 12, 26-day averages
- Bollinger Bands : Upper, middle, lower bands for volatility
- RSI (Relative Strength Index) : Overbought/oversold levels
- MACD : Trend and momentum analysis
- MACD Signal : Moving average of MACD
- MACD Histogram : MACD - Signal difference
- Volume SMA : 20-day average volume
- Volume Ratio : Current volume / average volume
- Pros : Fast, interpretable, good baseline
- Cons : Limited to linear relationships
- Best for : Quick analysis, educational purposes
- Pros : Handles non-linear relationships, feature importance
- Cons : Slower training, more complex
- Best for : Production use, detailed analysis
- MSE (Mean Squared Error) : Average squared prediction error
- RMSE (Root Mean Squared Error) : Square root of MSE
- MAE (Mean Absolute Error) : Average absolute prediction error
- Rยฒ (R-squared) : Proportion of variance explained (0-1)
- Price Chart : Historical prices with moving averages
- Volume Chart : Trading volume over time
- Technical Indicators : RSI, MACD, Bollinger Bands
- Predictions : Future price forecasts
- Prediction Table : Daily forecasts with dates
- Model Information : Feature importance and metrics
- Performance Summary : Model evaluation results
- LSTM Models : Deep learning for time series
- Multi-stock Comparison : Compare multiple stocks
- Portfolio Analysis : Risk and return metrics
- Real-time Alerts : Price movement notifications
- Backtesting : Historical performance validation
- API Integration : Real-time data feeds
pandas # Data manipulation
numpy # Numerical computing
matplotlib # Basic plotting
seaborn # Statistical visualization
scikit-learn # Machine learning
yfinance # Stock data download
streamlit # Web interface
plotly # Interactive charts
Educational Purpose Only: This tool is designed for educational and research purposes. Stock price predictions are inherently uncertain and should not be used as the sole basis for investment decisions. Always conduct thorough research and consider consulting with financial professionals before making investment decisions.
This project is licensed under the MIT License. See the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
If you encounter any issues or have questions:
- Check the troubleshooting section below
- Open an issue on GitHub
- Review the code comments for guidance
"No data returned for ticker"
- Verify the ticker symbol is correct
- Check your internet connection
- Try a different date range
"Missing required columns"
- This is usually a yfinance data issue
- Try the simplified version (
app_simple.py) - Use a different date range
Streamlit not loading
- Ensure all dependencies are installed
- Check if port 8501 is available
- Try
streamlit run app_simple.pyinstead
- Use Random Forest for better accuracy
- Longer date ranges provide more training data
- Recent data is more relevant for predictions
- Multiple indicators improve model performance