  Financial markets are highly complex and volatile; thus, learning about such
markets for the sake of making predictions is vital to make early alerts about
crashes and subsequent recoveries. People have been using learning tools from
diverse fields such as financial mathematics and machine learning in the
attempt of making trustworthy predictions on such markets. However, the
accuracy of such techniques had not been adequate until artificial neural
network (ANN) frameworks were developed. Moreover, making accurate real-time
predictions of financial time series is highly subjective to the ANN
architecture in use and the procedure of training it. Long short-term memory
(LSTM) is a member of the recurrent neural network family which has been widely
utilized for time series predictions. Especially, we train two LSTMs with a
known length, say $T$ time steps, of previous data and predict only one time
step ahead. At each iteration, while one LSTM is employed to find the best
number of epochs, the second LSTM is trained only for the best number of epochs
to make predictions. We treat the current prediction as in the training set for
the next prediction and train the same LSTM. While classic ways of training
result in more error when the predictions are made further away in the test
period, our approach is capable of maintaining a superior accuracy as training
increases when it proceeds through the testing period. The forecasting accuracy
of our approach is validated using three time series from each of the three
diverse financial markets: stock, cryptocurrency, and commodity. The results
are compared with those of an extended Kalman filter, an autoregressive model,
and an autoregressive integrated moving average model.

Machine Learning;Machine Learning