Stock market prediction using deep learning (LSTM)
This is an example of using deep learning (praticularly LSTM) for stock market prediction.
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:
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:
This file calculate the correlations between all the ticker. You can visualize the heat-map using visualize_data function:
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:
This file prepare the data for training. It concatenate price, trading volume, correlated tickers, and some indicators (MA, RSI, MACD).
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:
To comapre the prediction power, here is the plot for training data of MSFT:
-
Use more data (older histories), or shorter time frames (hourly)
-
Use more indicators and features.
-
Predict the next 10 days instead of the next day.