In this project, I demonstrate a comprehensive application of Long Short-Term Memory (LSTM) models to predict the future closing price of stocks given historical data. The selection of stocks includes prominent names like BlackRock, Goldman Sachs, JPMorgan Chase, and D. E. Shaw Group.
The project encompasses the entire lifecycle of a machine learning project, starting from data collection and pre-processing, model building and training, to evaluation and prediction.
The first step was utilizing the Yahoo Finance API to download historical stock data for selected companies, including open, high, low, close, and volume information for each trading day.
Preprocessing involved scaling the closing prices of stocks between 0 and 1, ensuring uniformity in the data and enabling effective model learning.
A LSTM model was used, consisting of two LSTM layers followed by dropout layers to prevent overfitting, and two Dense layers. LSTM networks are particularly suitable for time series data due to their ability to remember long-term dependencies.
The model was trained using:
Performance was assessed using Mean Squared Error (MSE) between actual and predicted stock prices.
The final step involved using the trained LSTM model to predict future stock closing prices.
To use this LSTM stock price prediction model:
git clone https://github.com/DhruvAjayToshniwal/Stock-Price-Prediction-Using-LSTM.git
pip install -r requirements.txt
This LSTM model allows users with basic Python knowledge to build and test stock price prediction models, potentially gaining insights into stock trading.
Future work includes: