This project is a real-time stock market prediction and analysis web app built using Python, Keras, and Streamlit. It predicts future stock prices using a deep learning model trained on historical stock data fetched from Stooq.
📽️ Click here to watch the demo video
- Stock price movements are highly volatile and influenced by complex patterns, making accurate forecasting challenging for investors and analysts.
- Traditional forecasting methods often fail to capture the non-linear trends and time-dependent nature of stock market data.
- There is a need for an intelligent, real-time system that can predict future stock prices using deep learning techniques, based on historical trends and patterns.
- This project aims to build a web-based application that leverages an LSTM model to forecast stock prices and visualize trends, helping users make more informed decisions.
- Uses statistical models, technical indicators, and fundamental analysis.
- Limited in handling complex patterns and time-based dependencies in stock data.
- Not well-suited for real-time market analysis.
- Struggles to adapt to fast-changing market conditions
- A machine learning-based approach using an LSTM model trained on historical stock prices.
- Utilizes free data from Stooq for accessibility.
- Predicts future prices and visualizes them with moving averages and comparison plots.
- Fully interactive and user-friendly interface built with Streamlit.
- Data Collection
- Data Preprocessing
- Feature Engineering
- Model Training
- Stock Price Prediction
- Visualization and Reporting
- 📊 Fetches historical stock data from 2010–2023 for any ticker (default: AAPL) using
pandas_datareader
. - 📉 Visualizes stock price trends with moving averages (100MA & 200MA).
- 🤖 Predicts future stock prices using a pre-trained LSTM model (
keras_model.h5
). - 📅 Displays predicted prices for the next 10 days using recent trends.
- 📈 Compares actual vs. predicted prices using interactive line plots.
- 🌐 Fully interactive web interface built using Streamlit.
- Python
- TensorFlow / Keras (LSTM model)
- Streamlit (for real-time UI)
- pandas (for data handling)
- matplotlib (for visualizations)
- scikit-learn (MinMaxScaler for normalization)
- pandas_datareader (fetching stock data from Stooq)
- User inputs a stock ticker (e.g.,
AAPL
). - App fetches historical data (2010–2023) from Stooq.
- Visualizes:
- Raw closing prices
- 100-day & 200-day moving averages
- Splits data into:
- 70% training
- 30% testing
- Uses an LSTM model to:
- Predict prices
- Compare with actual values
- Forecast the next 10 days
- All results are visualized and displayed on a real-time Streamlit dashboard.
While no explicit metric (like RMSE or R²) is shown in the app, the LSTM model demonstrates approximately 85% trend accuracy, based on visual comparison of actual vs. predicted curves.
-
Clone the repository: Clone the project repository to your local machine using Git (or download as ZIP): git clone <repo_url>
-
Set up a virtual environment: Open a terminal and navigate to the project folder. Then create and activate a virtual environment:
For Windows: python -m venv venv venv\Scripts\activate
For macOS/Linux: python3 -m venv venv source venv/bin/activate
-
Install required dependencies: Once your virtual environment is active, install the required packages using the requirements.txt file: pip install -r requirements.txt
-
Run the Streamlit app: To start the Streamlit web app, run the following command in your terminal: streamlit run app.py
-
Access the web app: After running the command, Streamlit will automatically open the app in your default web browser. If not, you can manually open the following URL in your browser: http://localhost:8501
-
Enter a Stock Ticker: In the web interface, you can enter any stock ticker (e.g., AAPL) into the search bar. The app will fetch and display: Historical stock data (from 2010 to 2023). Stock price predictions for the next 10 days.