Skip to content

Amir-Ebrahimi66/SP500-prediction-using-LSTM

Repository files navigation

SP500-prediction-using-LSTM

Stock market prediction using deep learning (LSTM)

This is an example of using deep learning (praticularly LSTM) for stock market prediction.

Files:

ReadS&P500.py

This file extract S&P500 tickers and also add commodities, currencies, indices, and crypto-currencies. The extracted data will be stored to S&P500-Info.csv and S&P500-Symbols.csv The files look like:

image

ReadDataAll.py

This file reads data from each ticker using Yahoo finance API. We will store the price data of each ticker in All_1d.pickle and the trading volume of each ticker in All_1dv.pickle like:

image

CreateCorrelation.py

This file calculate the correlations between all the ticker. You can visualize the heat-map using visualize_data function:

image

Also, this file calculate the top 5 and buttom 5 correlated tickers related to each particular ticker to store in Top_Bottom_Five_Correlated_Names:

image

TrainTicker.py

This file prepare the data for training. It concatenate price, trading volume, correlated tickers, and some indicators (MA, RSI, MACD).

Main.py

This file train an LSTM model for a particular ticker. It calls the necessary functions and data from previous files, normalize the data, split data for training and test before creating a model. The goal is to predict the next-day price with 100 historical data.

The current LSTM model is like:

model

To comapre the prediction power, here is the plot for training data of MSFT:

image

Future work:

  1. Use more data (older histories), or shorter time frames (hourly)

  2. Use more indicators and features.

  3. Predict the next 10 days instead of the next day.

About

Stock market prediction using deep learning (LSTM)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages