Predicting Stock Market Movements Using Artificial Neural Networks

Knowing about the future returns attract every investor. Investors can take appropriate decisions once they know what would be the future returns based on their investments. To know the returns, the earlier studies have proposed basic models like Efficient Marker Hypothesis and Random Walk Model, whereas these theories have their own limitations in predicting the direction of the stock and the next day value of the stock. Later with the evolution of Machine learning and Deep Learning Techniques, there were many experiments which were made to study the stock markets. The present research paper aims at applying the Deep Learning technique of Artificial Neural Network to predict the direction of the stock index. The data consist of daily open price, close price, high price, low price and volume of NIFTY 50, S&P 500, New York Stock Index, Korean Stock Index, Dow Jones Index and Shanghai Stock Index from Jan 2015 to May 2020. The open price of the index is fed as input to the Artificial Neural Network. The model is evaluated on different performance metrics of Accuracy, Precision, Recall and F1-Score.


Introduction
Foreign Investments are one of the instruments that makes the investor to expect higher returns. Investing in different indices is one area which requires an in depth study to analyse different stocks in different stock markets. Every country has its own financial policy to determine which stocks are to be listed in stock exchange however the mechanism of operation remains the same.
For a Business investment is the most important fact to keeps its operations running. Hence businesses can raise the capital in different ways. One of the most popular ways is through stocks.
Some of the financial institutions that emerged taking investment as prime function include central banks, inter-governmental organizations and multilateral treaties. capital market is considered significant as it paves way for raising money in different innovative ways. This is made more effective after gains are tasted by investors -both retail and institutional.
Predicting the stock market is a research area which is having long history. This research has taken many turns and twists whenever there were innovative models to find the nearest possible forecast. But still, it is not so, as accuracy of the next move in stock price is still not acceptable as the market follows random walk. Hence a better forecast makes the investors and a researcher happier.
A overwhelming growth is observed in emerging markets during the last two decades. Market like India, China, South Africa have attracted more investors as the returns are high when compared with the developed markets like America, Australia etc.,. Hence this paper focuses on both emerging market indices and developed market indices for the predicting the stock movement.
The prediction accuracy of Deep Neural Networks using Artificial Neural Network (ANN).
The paper is organised in to different sections. Literature survey is presented in section 2, data extraction and methodology is described in section 3 and section 4 gives the analysis and discussion followed by conclusion in section 5.

Literature Survey
This section talks about the past work done by researchers in the area of prediction using Artificial Neural Network.

1. Artificial Neural Network
Artificial Neural Networks (ANN) have emerged since1970s but are found to be most popular in recent times because of increase in the computational power of the computers. ANNs are one of the models of Deep learning Algorithms. They evolved based on the biological functioning of human brain. As human brain learn from the past experience similarly ANNs learn from the past data. ANNs are found to be capable of predicting and classifying the data. ANNs deal with non-linear data which are capable of building complex relations and help in identifying the new trends and patterns. The major application of this network model includes face recognition, image processing, natural language processing and medical diagnosis.
The following gives an extensive literature survey on application of Machine Learning Techniques -Artificial Neural Network and ARIMA Models in forecasting the direction of the stock movement and the closing price of the stock.
Manna Majumder [1] Predicted next day S&P CNX Nifty 50 index with an accuracy rate of 89.65 per cent. This study used ANN for this prediction and found that the average accuracy stood at 69.72 percent over four period of time.
Bjoern Krollner [2] states that Artificial Neural Network (ANN) is A dominant algorithm in identifying the trade-off between risk return of the investors.
Lufuno Ronald Marwala [3] in his dissertation used NN, Support machines and neuro-fuzzy systems in ANN model to forecast stock market index. These algorithms when compared to ARMA and Random Walk model showed that SVM outperformed in accuracy when MSE and RMSE are taken as error metrics.
Alotaibi, et al [4], Describes ANN as an efficient tool in prediction and applied in the study to forecast Saudi Arabian Stock index and Oil prices. They used back ward propagation to predict the movement. They suggest Median and Closing price carry best input features. The study attributes Trainbr a Bayesian regularization function for getting the high accuracy rate. Qiu Mingyue [5] in his research stated that Artificial Neural Network is an essential tool to predict the Tokyo Stock Index Nikkei using Back propagation and suggested that the two drawbacks of ANN are the convergence and inability of local minima hence he applied Genetic Algorithm and Simulated annealing to improve the accuracy of ANN model. In order to evaluate the performance of the model Mean Squared Error is used.

Data Extraction and Methodology
This section deals with the source of data and the data pre-processing technique which is been adopted before training Artificial Neural Network.

Source of Data
The data used for predicting the stock market indices is collected from secondary source through stock market websites. The time period selected for the study is between Jan 2015 to May 2020 which constitutes 1324 samples. The dataset consists of High Price, Low Price, Open Price and Closing price of intraday data of selected stock index. The daily closing price of the stock index is considered as the input variable to predict one day stock index by using Deep learning neural networks i.e., Artificial Neural Network (ANN) and Recurrent Neural Network (RNN).

Deep Learning Algorithms
Deep Learning is a branch of Artificial Intelligence which deals with unsupervised learning. It uses networks to train the data and predict the unlabelled data too. It has the ability to deal with large datasets. There are different types if Deep Learning Algorithms; Artificial Neural Network, Deep Neural Network or Convolution Neural Network and Recurrent Neural Network.
An Artificial Neural Network consists of three layer. First layer being the input layer receives the input from the data that is required to be processed. Inputs can be image, text or a numeric data. The second layer being the hidden layer can be said as the processing layer takes the input data process through each neuron by generating the weights. Once the weights got generated then complex mathematical function will be used to process the input at each neuron. The complex mathematical functions that are used in a network to process the weighted inputs are called as activation functions. The last layer is the output layer and projects the output.
There are many activation functions that are been used in an ANN for processing the data. Most popularly used activation function are Sigmoid if the output is a categorical or binary response, Rectified Linear Unit (ReLU) if the output is from 0 to 1 and tanh if the output ranges from -1 to +1. Activation functions are the functions used to activate a neuron in neural network. These activation functions verify whether the information received by the neuron is relevant or to be ignored. Activation function transforms the input signal and the output received is fed as input signal in the next layer of neurons.
Actually there are many types of activation function used in neural networks. The basic activation function is ∝ (x) = ∑ which is weighted average.

Y = Activation (∑ (Weight * Input) + bias)
Every neural network is processed on different parameters that will be considered to determine the goodness of the model. Some of the parameters that are to be considered in ANN include weight bias, learning rate, batch size and epochs.
Once ANN generates the output and the network is then evaluated based on the error values. Later the weights can be adjusted through back propagation in order to improve the accuracy of the model prediction. There are various metrics which are used to evaluate the model performance.
In this study five days closing price of the stock index is fed as input to ANN model to predict the direction of the stock index. And processed through two hidden layers with 100 epochs using "Rectified Linear Unit (relu)" as activation function.

Performance Metrics Considered for the Study
As the proposed methodology is to determine the direction of the stock index. Various metrics are been considered for evaluating the performance of the Artificial Neural Network. Below is the list of performance metrics considered for the study.
Precision: It is the ratio of correctly predicted positives to the total predicted positive observations. High precision relates to the low false positive rate. Precision = TP/TP+FP Recall: It is the ratio of correctly predicted positive observations to the all observations in actual class. Generally recall value above 0.5 is considered to be reasonably good.
Recall = TP/TP+FN F1 Score: It is the harmonic mean of precision and recall this is most accurate measure than accuracy.
F1-Score = 2 * (Recall * Precision)/ Recall +Precision F1-Score is a best measure when the classification of the target is imbalanced.
Accuracy: Accuracy determines the how good the model is, in classifying the target variable.   NIFTY 50 the performance metric of Recall is found to be higher when the market is moving towards the positive direction representing bullish market which means that intra day trading for the period of past one year (May 2019 to May 2020) is found to be showing an uptrend trend. And the accuracy at which Artificial Neural Network is able to predict the direction of the stock index is found to be 51%.

Results and Conclusions
Dow Jones Index the performance metric of Recall is found to be higher when the market is moving towards the positive direction representing bullish market which means that intraday trading for the period of past one year (May 2019 to May 2020) is found to be showing an uptrend trend. And the accuracy at which Artificial Neural Network is able to predict the direction of the stock index is found to be 51%.
S&P 500 index has high recall on predicting the positive movement of the stock index. Kospi and Newyork has the same direction of the stock when looked at their recall values. But China Shanghai Stock Exchange has highest recall value representing the longer duration of positive movement in the stock index.
It is observed from the above table that the accuracy of prediction for all the selected five stocks is around 53%. Precision and Recall states that out of 1349 observations 54% and 16% of the observations out of the selected stocks are been accurately predicting the direction of the stock index. Since F1 Score is approximately around 0.65 in predicting the movement of the stock.

Conclusion
Based on the above results it is clear that ANN is able to predict the direction of the stock index with 53% when 5 days closing price of the stock is given as input to the network and processed on two hidden layers.
Artificial Neural Networks were found to have handled the outliers in the data where the events of demonetisation and Pandemic were been involved. The accuracy of predicting the direction of the stock movements of NIFTY 50, India and China (SSE) is found to be less because these are densely populated and affected with pandemic. Hence it is concluded Artificial Neural Networks are good at handling events and the uncertain factors in the data. But this model includes only short term prediction. The future scope of work suggests to apply recurrent neural network which has memory state to remember recent trends and other machine learning algorithms.