Skip to content

Stock price prediction application with interactive web interface. Features multiple ML models (Linear Regression, Random Forest), 19+ technical indicators, alerts system, and real-time market data visualization.

License

Notifications You must be signed in to change notification settings

Rayyan-Oumlil/StockPricePredictor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

15 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

StockPricePredictor

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.

๐Ÿ“Š Web Interface with Streamlit

  • 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

๐Ÿ”ง Advanced Technical Indicators

  • 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

๐Ÿค– Enhanced Machine Learning

  • 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

๐Ÿ”” Alerts System

  • 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

๐Ÿ“Š Multi-Page 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

๐Ÿ“ Project Structure

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

๐ŸŽฏ Quick Start

Option 1: Web Interface (Recommended) ๐ŸŒ

Launch the main application:

streamlit run App.py

Then open your browser to: http://localhost:8501

Option 2: Command Line Interface ๐Ÿ’ป

python main.py --ticker AAPL --start 2023-01-01 --end 2024-01-01 --model random_forest --forecast_horizon 7

๐Ÿ›  Installation

  1. Clone the repository:
git clone <repository-url>
cd StockPricePredictor
  1. Create virtual environment:
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install dependencies:
pip install -r requirements.txt

๐Ÿ“Š Usage Examples

Web Interface

Main App:

  1. Select Stocks : Choose multiple tickers (AAPL, MSFT, TSLA, etc.)
  2. Set Date Range : Pick start and end dates
  3. Choose Model : Linear Regression or Random Forest
  4. Set Forecast Days : 1-30 days into the future
  5. 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

Command Line

# 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

๐Ÿ”ง Technical Indicators

๐Ÿ“ˆ Price-based Indicators

  • 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

๐Ÿ“Š Momentum Indicators

  • RSI (Relative Strength Index) : Overbought/oversold levels
  • MACD : Trend and momentum analysis
  • MACD Signal : Moving average of MACD
  • MACD Histogram : MACD - Signal difference

๐Ÿ“ˆ Volume Indicators

  • Volume SMA : 20-day average volume
  • Volume Ratio : Current volume / average volume

๐Ÿค– Machine Learning Models

Linear Regression

  • Pros : Fast, interpretable, good baseline
  • Cons : Limited to linear relationships
  • Best for : Quick analysis, educational purposes

Random Forest

  • Pros : Handles non-linear relationships, feature importance
  • Cons : Slower training, more complex
  • Best for : Production use, detailed analysis

๐Ÿ“Š Performance Metrics

  • 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)

๐ŸŽจ Visualizations

Interactive Charts

  • Price Chart : Historical prices with moving averages
  • Volume Chart : Trading volume over time
  • Technical Indicators : RSI, MACD, Bollinger Bands
  • Predictions : Future price forecasts

Data Tables

  • Prediction Table : Daily forecasts with dates
  • Model Information : Feature importance and metrics
  • Performance Summary : Model evaluation results

๐Ÿ”ฎ Future Enhancements

  • 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

๐Ÿ“‹ Dependencies

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

โš ๏ธ Disclaimer

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.

๐Ÿ“„ License

This project is licensed under the MIT License. See the LICENSE file for details.

๐Ÿค Contributing

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.

๐Ÿ“ž Support

If you encounter any issues or have questions:

  1. Check the troubleshooting section below
  2. Open an issue on GitHub
  3. Review the code comments for guidance

๐Ÿ”ง Troubleshooting

Common Issues

"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.py instead

Performance Tips

  • 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

About

Stock price prediction application with interactive web interface. Features multiple ML models (Linear Regression, Random Forest), 19+ technical indicators, alerts system, and real-time market data visualization.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages