Professional Documents
Culture Documents
© 2018, IRJET | Impact Factor value: 6.171 | ISO 9001:2008 Certified Journal | Page 3342
International Research Journal of Engineering and Technology (IRJET) e-ISSN: 2395-0056
Volume: 05 Issue: 03 | Mar-2018 www.irjet.net p-ISSN: 2395-0072
An alternative approach to stock market analysis is to reduce LSTM's are a special subset of RNN’s that can capture
the dimensionality of the input data [2] and apply feature context-specific temporal dependencies for long periods of
selection algorithms to shortlist a core set of features (such time. Each LSTM neuron is a memory cell that can store other
as GDP, oil price, inflation rate, etc.) that have the greatest information i.e., it maintains its own cell state. While neurons
impact on stock prices or currency exchange rates across in normal RNN’s merely take in their previous hidden state
markets [10]. However, this method does not consider long- and the current input to output a new hidden state, an LSTM
term trading strategies as it fails to take the entire history of neuron also takes in its old cell state and outputs its new cell
trends into account; furthermore, there is no provision for state.
outlier detection.
An LSTM memory cell, as depicted in Figure 1, has the
4. PROPOSED SYSTEM following three components, or gates:
We propose an online learning algorithm for predicting the 1. Forget gate: the forget gate decides when specific
end-of-day price of a given stock (see Figure 2) with the help portions of the cell state are to be replaced with
of Long Short Term Memory (LSTM), a type of Recurrent more recent information. It outputs values close to 1
Neural Network (RNN). for parts of the cell state that should be retained, and
zero for values that should be neglected.
4.1 Batch versus online learning algorithms
2. Input gate : based on the input (i.e., previous output
o(t-1), input x(t), and previous cell state c(t-1)), this
Online and batch learning algorithms differ in the way in
section of the network learns the conditions under
which they operate. In an online algorithm, it is possible to
which any information should be stored (or
stop the optimization process in the middle of a learning run
updated) in the cell state
and still train an effective model. This is particularly useful
for very large data sets (such as stock price datasets) when 3. Output gate: depending on the input and cell state,
the convergence can be measured and learning can be quit this portion decides what information is propagated
early. The stochastic learning paradigm is ideally used for forward (i.e., output o(t) and cell state c(t)) to the
online learning because the model is trained on every data next node in the network.
point — each parameter update only uses a single randomly
chosen data point, and while oscillations may be observed, Thus, LSTM networks are ideal for exploring how variation in
the weights eventually converge to the same optimal value. one stock's price can affect the prices of several other stocks
On the other hand, batch algorithms keep the system weights over a long period of time. They can also decide (in a dynamic
constant while computing the error associated with each fashion) for how long information about specific past trends
sample in the input. That is, each parameter update involves a in stock price movement needs to be retained in order to
scan of the entire dataset — this can be highly time- more accurately predict future trends in the variation of stock
consuming for large-sized stock price data. Speed and prices.
accuracy are equally important in predicting trends in stock
price movement, where prices can fluctuate wildly within the 4.3 Advantages of LSTM
span of a day. As such, an online learning approach is better
for stock price prediction. The main advantage of an LSTM is its ability to learn context-
specific temporal dependence. Each LSTM unit remembers
4.2 LSTM – an overview information for either a long or a short period of time (hence
the name) without explicitly using an activation function
within the recurrent components.
© 2018, IRJET | Impact Factor value: 6.171 | ISO 9001:2008 Certified Journal | Page 3343
International Research Journal of Engineering and Technology (IRJET) e-ISSN: 2395-0056
Volume: 05 Issue: 03 | Mar-2018 www.irjet.net p-ISSN: 2395-0072
Additionally, LSTM’s are also relatively insensitive to gaps Here, the sigmoid and ReLU (Rectified Linear Unit)
(i.e., time lags between input data points) compared to other activation functions were tested to optimize the
RNN’s. prediction model.
© 2018, IRJET | Impact Factor value: 6.171 | ISO 9001:2008 Certified Journal | Page 3344
International Research Journal of Engineering and Technology (IRJET) e-ISSN: 2395-0056
Volume: 05 Issue: 03 | Mar-2018 www.irjet.net p-ISSN: 2395-0072
In general, smaller the RMSE value, greater the accuracy of The obtained data contained five features:
the predictions made.
1. Date: of the observation
5. OVERALL SYSTEM ARCHITECTURE 2. Opening price: of the stock
3. High: highest intra-day price reached by the stock
4. Low: lowest intra-day price reached by the stock
5. Volume: number of shares or contracts bought and
sold in the market during the day
6. OpenInt i.e., Open Interest: how many futures
contracts are currently outstanding in the market
© 2018, IRJET | Impact Factor value: 6.171 | ISO 9001:2008 Certified Journal | Page 3345
International Research Journal of Engineering and Technology (IRJET) e-ISSN: 2395-0056
Volume: 05 Issue: 03 | Mar-2018 www.irjet.net p-ISSN: 2395-0072
The input data is split into training and test datasets; our 6. VISUALIZATION OF RESULTS
LSTM model will be fit on the training dataset, and the
accuracy of the fit will be evaluated on the test dataset. The Figure 9 shows the actual and the predicted closing stock
LSTM network (Figure 7) is constructed with one input layer price of the company Alcoa Corp, a large-sized stock. The
having five neurons, 'n' hidden layers (with 'm' LSTM model was trained with a batch size of 512 and 50 epochs,
memory cells per layer), and one output layer (with one and the predictions made closely matched the actual stock
neuron). After fitting the model on the training dataset, prices, as observed in the graph.
hyper-parameter tuning is done using the validation set to
choose the optimal values of parameters such as the number
of hidden layers 'n', number of neurons 'm' per hidden layer,
batch size, etc.
© 2018, IRJET | Impact Factor value: 6.171 | ISO 9001:2008 Certified Journal | Page 3346
International Research Journal of Engineering and Technology (IRJET) e-ISSN: 2395-0056
Volume: 05 Issue: 03 | Mar-2018 www.irjet.net p-ISSN: 2395-0072
Data Size Stock Name LSTM ANN [2] Soulas, Eleftherios, and Dennis Shasha. “Online machine
(RMSE) (RMSE) learning algorithms for currency exchange prediction.”
Small Dixon 0.04 0.17 Computer Science Department in New York University,
Hughes Tech. Rep 31 (2013).
© 2018, IRJET | Impact Factor value: 6.171 | ISO 9001:2008 Certified Journal | Page 3347
International Research Journal of Engineering and Technology (IRJET) e-ISSN: 2395-0056
Volume: 05 Issue: 03 | Mar-2018 www.irjet.net p-ISSN: 2395-0072
[8] Ding, Y., Zhao, P., Hoi, S. C., Ong, Y. S. “An Adaptive
Gradient Method for Online AUC Maximization” In AAAI
(pp. 2568-2574). (2015, January).
[9] Zhao, P., Hoi, S. C., Wang, J., Li, B. “Online transfer
learning”. Artificial Intelligence, 216, 76-102. (2014)
© 2018, IRJET | Impact Factor value: 6.171 | ISO 9001:2008 Certified Journal | Page 3348