This repository contains a Flask web application for predicting stock prices using Long Short-Term Memory (LSTM) neural networks. The application fetches historical stock data from Yahoo Finance API (yfinance
), preprocesses the data by adding moving average features, normalizes it using Min-Max scaling, and trains LSTM models with different hyperparameters.
- Data Preprocessing: Includes adding moving average features to enhance model performance.
- Model Training: Utilizes LSTM models with varying architectures (layers, hidden dimensions, dropout) to predict stock prices.
- Hyperparameter Tuning: Grid search over predefined parameters to optimize model performance.
- Web Application: Built using Flask to allow users to input a stock ticker symbol and a date, then receive predictions for future stock prices.
- Visualization: Generates plots using
matplotlib
to visualize predicted prices and backtesting results. - Backtesting Strategy: Evaluates a simple trading strategy based on predicted signals.
- Python
- Flask
- PyTorch (for LSTM models)
yfinance
(Yahoo Finance API)matplotlib
(for plotting)sklearn
(for data preprocessing)
- Clone the repository:
git clone https://github.com/ChellaVigneshKP/stock-prediction.git
- Start the Flask application:
python app.py
- Navigate to http://localhost:5000 in your web browser.
- Enter a stock ticker symbol and a recent date to get predictions and backtesting results.