This project aims to predict the closing prices of stocks in the Nifty 50 index using a Long Short-Term Memory (LSTM) neural network model. The predictions are visualized through a user-friendly web application built with Streamlit.
- Introduction
- Features
- Requirements
- Installation
- Usage
- Model Training
- Model Performance
- Prediction
- Contributing
- License
Stock price prediction is a challenging task due to the volatile nature of the stock market. This project leverages the capabilities of LSTM neural networks to forecast future stock prices based on historical data. The web application provides an interactive way to visualize past trends and the predicted closing prices.
- Data Retrieval: Fetches historical stock price data from Yahoo Finance.
- Data Preprocessing: Normalizes the data using MinMaxScaler for better model performance.
- LSTM Model: Utilizes a deep learning LSTM model to predict future stock prices.
- Interactive Visualization: Displays stock price trends and predictions using Plotly and Streamlit.
- Real-time Prediction: Provides real-time stock price predictions based on the latest available data.
- Python 3.8+
- pandas
- numpy
- matplotlib
- seaborn
- yfinance
- scikit-learn
- tensorflow
- keras
- joblib
- streamlit
- plotly
-
Clone the repository:
git clone https://github.com/your-username/nifty-prediction.git cd nifty-prediction
-
Create a virtual environment:
python -m venv venv venv\Scripts\activate
-
Install the required packages:
pip install -r requirements.txt
-
Train the Model:
- Run the training script to train the LSTM model on historical data:
python train_model.py
-
Run the Streamlit Application:
- Start the Streamlit application to visualize and predict stock prices:
streamlit run nifty_predictor.py
-
Access the Application:
- Open your web browser and navigate to http://localhost:8501 to interact with the application.
The model is trained using historical stock price data. The LSTM network is designed to capture temporal dependencies in the data. The training script includes data preprocessing, model architecture definition, and training routines.
The Streamlit application allows users to predict future stock prices based on the latest available data. The application displays the historical trend, predicted values, and highlights the prediction points on the chart.
- Retrain the model with more layers to predict a long term trend
- Check & update the model periodically, if required
- Add gold, debt, G Sec, Dow Jones / Nasdaq as additional features and train the neural network
- With step 3 - consider adding risk factor like Monte Carlos and try creating a equity meter for asset allocation
Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.
This project is licensed under the MIT License.