How ANN predicts Stock Market Indices ?

### **SHORT ANSWER**

Stock market is a platform where investors buy and trade stocks or shares of companies. Investors can be small stock investors or institutional investors such as banks, insurance companies and mutual funds. Stocks or shares of companies are the investments to companies in smaller proportions for which investors get slice of ownership. Investors get paid profit in form of dividends, when companies are profitable, stock market investors make money through the dividends that the companies pay out and by selling the appreciated stocks yields profit called as capital gain. Stock market is the most preliminary way to raise money for the companies. By publicly selling stocks and shares, companies raise additional capital for expansion of their ventures. Advantage that the stock market offers is that the investors can easily exchange or trade their stocks anytime. This is an attractive feature compared to investments on immovable properties. Nowadays, significant portion of the funds related to saving and financing, flows to stock market investments instead of being routed to bank deposit and lending operations. Sources for such investment come from mutual funds, insurance investments, pension funds, etc.

History of public investments date back to 13th century when venetian bankers started investing in government securities. In 16th century Italian companies were first to issue shares followed by companies in England. At Amsterdam exchange, the Dutch East India Company with continuous trade in stock was the first stock company to get a fixed capital stock. Since then many developed and developing countries have established and large markets.

Increased business means rising stock prices and this rise is considered to be an up-coming economy. A country’s economy is indicated by strength of its stock market. Stock market or share market fall will effect a nation. First impact is that people will see fall in the value of their wealth. Reduction in pension value, reduces confidence of investor preventing the ability of the firm raising funds who raise funds by issuing more shares. Although people who decide to buy stocks are prepared to lose money. But losing money on the shares will make them hesitant to spend money on consumer products resulting in fall in consumer spending. This in-turn reduces profit that companies make and hits back at stock market and results in down-fall in economy of a country. We have had many examples of country’s economy getting affected due to the fall of stock market. One such great example is the “wall street crash of 1929” which was the most devastating stock market crash in the history of United States. This crash in the stock market resulted in a 10 year depression that affect all industries and industrialized countries. By 1920s U.S. stock market witnessed rapid expansion reaching its peak in August 1929 [9]. Excess production and rising stock market declined consumer demand. After reaching peaks, stock market witnessed steep fall due to which people sold their stocks and by 1932, stocks were worth of only 20% of their value when stock market reached its peaks. Stock market crash is considered as Great Depression, where half of the American banks failed and almost 30% of the America’s workforce were unemployed. This calls for the future insight of stock market. Wall Street Crash of 1929 is shown in the below figure .

In past, there have been attempts made to predict stock market. Stock market prediction involves various factors and doesn’t have any mathematical relation with the indices of the stock market. Prediction of stock market comes as a big challenge. The various factors affecting rise or fall of stock market are the fundamental factors such as profit or dividends, margins of the share or stock market. Apart from the fundamental factors, there are various other factors that influence the stock prices. Other factors that influence stock market are the internal developments in companies, scandals, world events like natural calamities and civil unrest. Higher interest rates set by federal banks and reserve banks of countries might make the investors to sell or trade their stocks to avoid higher interest rates. Impact of exchange rates affects the business in foreign countries and thus affecting stock market. Although factors apart from fundamental factors can be considered as noise. But, it is difficult to ignore these factors while predicting the stock market.

The act of determining the future value of stock of companies is called stock market prediction. Stock prediction can yield significant profit to the investor investing on stocks of different companies. Prediction is purely based on the previous stock values and it depends on different factors making prediction arduous process. There have been attempts made to predict stock market at all levels using different analysis methods. Different analysis methods used to predict are fundamental analysis, technical analysis, time series analysis and machine learning techniques.

Machine learning analysis uses artificial intelligence to predict stock market. Usually artificial neural network is used as human brain, fed with massive data to interpret stock market. Since there is no mathematical relation between inputs and outputs of the predicted values, artificial neural networks determines the hidden patterns and unknown parameters involved in prediction. Artificial neural network will predict stock market using the past experience that the system has learnt. For the artificial neural network to predict, system has to learn the effects of the various factors affecting the indices of the data to be predicted. For the system to predict, system undergoes two process, one being learning process and learnt process that is used to predict. During learning process, data of previous days are fed on to the system and the computed output is compared with the actual stock prices of the previous days. The error in the predicted value is used to correct the system and thus helping the system reduce errors during prediction.

The prime component of an artificial neural network is a neuron similar to the neuron in the human brain. Neuron in artificial neural network is considered as the mathematical function. Artificial neural network consists of several neurons connected to each other. Cluster of neurons can compute complex computations. There is three layer of neurons used in the prediction of stock market, those are the input layer, output layer and the hidden layer where the computation takes place for the prediction. Number of neurons in the input layer is decided by the number of inputs being provided for the prediction. Connection between neurons has weights associated with it to signify the strength of connection between neurons. Errors calculated after prediction in learning phase is used to update weights so that system reduces errors to
obtain exact prediction. System identifies the input data as significant and insignificant data required for prediction. Artificial neural network does not make use of insignificant data for prediction once the system is ready for prediction after learning phase.

### **LONG ANSWER**

#### **Artificial neurons:**

As we see in biological neural network or the structure, the transmission of the signal from one neuron to another takes place through synapses which is a chemical process in which specific substances are released from the sending side of the junction to receiving side. The concept of artificial network was developed based on such transfer process. The biological neurons are the inspiration for designing artificial neural network. The electric signal is raised or lowered inside the receiving cell or junction. There is a threshold value which decides the raise and lowering of signal at receiver end. If the graded potential is higher than the threshold value, then the neutron fires. The below figure is the widely used example block for a single neuron. Based on the requirements, slight modifications are done for neuron structures.

The structure of the artificial neuron given in above figure has N inputs which are denoted as *u*1, *u*2…*uN* and one output which is denoted by *x.* Each input to the neuron has a weight which are denoted by *w1,w2…wN*. The threshold in the artificial neuron is generally represented by 𝜃. The activation factor for each neuron is represented by ‘𝑎’. The formula for calculating activation factor is given by the below formula.

The inputs and the weights are generally real values. A negative value for weight indicates inhibitory connection and the positive connection represents excitatory connections. For simplicity, we can combine the threshold value with the summation part. Let us assume that the input *u0* = +1.  And the weight *w0*= 𝜃. Hence the activation formula is given by,

The output value of the artificial neuron is a function of its activation function. Thus, *x* can be given by the below formula,

#### **Artificial neural network**

In machine learning and cognitive science, **artificial neural networks** (**ANNs**) are biological neural networks which are used to approximate functions which depends on large number of inputs and provide an output. Artificial neural networks are represented as systems of interconnected or clustered "neurons" which exchange signals and messages between each other. The connections have weights which can be tuned based on experience, making neural adaptive to inputs and capable of learning based on output. A single neuron cannot be used to develop or design a complete Boolean function, thus we use a cluster of neurons. The cluster of neurons together is called as artificial neural network. By using this cluster of neurons we can design and develop huge Boolean functions. In such a cluster of neurons, we provide each neuron with particular indices to identify them. We don’t have to understand the system or the network, as it trains itself. This is one of the major advantage of ANN [1]. Another advantage of the network is it will learn ignoring the data which does not improve the output of the system in the training phase [1, 2]. Thus to activate *ith* neuron, the formula shown below can be used,

Where *xj* represents the output of another neuron or an external input for the network.

There is a training phase where parameters called as weights are found from the sample used for
training and back propagation algorithm is used for this training of network. These updated weights are used in prediction phase using the same equation formed by the network developed in training period.

There are many types of artificial neural networks based on the user requirements. Here, we are considering **feedforward** neural network which is shown in the below figure. The neurons in the network forms many layers between inputs and output. Neurons in the network get the data from the input signals or from the previous nodes or neurons. The last layer is called as output layer and the first layer is called as input layer. And the in between layers are called as hidden layers or middle layers. If there is one single hidden layer, then it’s called as single layer network. Else if there are many layers in the hidden layers, then it’s called as multilayer networks. In this particular project, we are considering the feedforward network with back propagation algorithm. Back propagation learning algorithm is discussed below.

####