Skip to content

ShengyuanWang/LSTM-Stock-market-Prediction

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

70 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stock Price Prediction and Profit Optimization

This project aims to predict stock prices using Long Short-Term Memory (LSTM) and Autoregressive Integrated Moving Average (ARIMA) models. The goal is to leverage these predictions to optimize profit by making informed trading decisions based on the anticipated price changes.

Table of Contents

Introduction

In this project, we combine LSTM and ARIMA models to predict stock prices and generate optimal trading strategies. The LSTM model is a type of recurrent neural network (RNN) that is well-suited for capturing long-term dependencies in time series data. ARIMA, on the other hand, is a statistical model that can handle non-stationary time series data by incorporating differencing, autoregression, and moving average components.

By using historical stock price data, we train these models to predict future price changes. These predictions are then used to optimize profit by making buy or sell decisions at specific points in time.

Installation

To set up the project locally, follow these steps:

  1. Clone the repository:
git clone https://github.com/your-username/stock-price-prediction.git

2.Navigate to the project directory:

cd stock-price-prediction

3.Install the required dependencies. It is recommended to use a virtual environment for this step:

pip install -r requirements.txt

4.Once the dependencies are installed, you are ready to use the project.

Usage

To use the stock price prediction and profit optimization models, follow these steps:

  • Prepare the data by following the instructions provided in the Data Preparation section.

  • Train the LSTM and ARIMA models using the prepared data. Details about the models and training process can be found in the Models section.

  • Generate predictions for future stock prices using the trained models.

  • Utilize the predicted price changes to make buy or sell decisions at specific points in time to optimize profit.

Data Preparation

To train the models and generate accurate predictions, you need historical stock price data. Ensure that you have a dataset containing at least the following columns:

  • Date: The date associated with each stock price.
  • Close: The closing price of the stock on the given date.
  • Perform any necessary preprocessing steps, such as handling missing values or scaling the data, before using it for training and prediction.

Models

This project utilizes two models: LSTM and ARIMA.

  • LSTM (Long Short-Term Memory) The LSTM model is a type of recurrent neural network (RNN) that is effective in capturing long-term dependencies in time series data. It consists of LSTM cells that store and update information over long periods. By training the LSTM model on historical stock price data, it learns to predict future price changes.

  • ARIMA (Autoregressive Integrated Moving Average) ARIMA is a statistical model used for time series forecasting. It incorporates autoregressive (AR), differencing (I), and moving average (MA) components to handle non-stationary time series data. ARIMA models can be used to forecast future stock price changes based on historical data.

Results

The project's performance is evaluated based on prediction accuracy and profit optimization. The accuracy of the models can be measured using metrics such as mean squared error (MSE) or mean absolute error (MAE).

To assess the profit optimization strategy, calculate the profit generated based on the predicted price changes and compare it to a baseline strategy (e.g., a buy-and-hold approach). Analyze metrics such as total profit, return on investment (ROI), or risk-adjusted return to evaluate the effectiveness of the optimization strategy.

Conclusion

This project demonstrates the use of LSTM and ARIMA models to predict stock prices and optimize profit based on these predictions. By combining deep learning techniques and statistical modeling, it provides insights into future price changes and suggests trading strategies to maximize profitability.

Contributing

Contributions to this project are welcome. If you would like to contribute, please follow these guidelines:

Fork the repository. Create a new branch for your feature or bug fix. Make your changes and commit them with descriptive commit messages. Push your changes to your fork. Submit a pull request, explaining the changes you made.

License

This project is licensed under the MIT License. You are free to use, modify, and distribute the code in accordance with the terms and conditions of the license.

About

Code repo for 2022 MCM Competition (LSTM and DP for stock market prediction)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors