Neural Network In Python: Introduction, Structure And Trading Strategies – Part II

Articles From: QuantInsti
Website: QuantInsti

In the first installment, Devang discussed the structure of a neuron, and the concept of a perceptron, which is a computer neuron.

Understanding a Neural Network

We will look at an example to understand the working of neural networks. The input layer consists of the parameters that will help us arrive at an output value or form an outlook. Our brains essentially have five basic input parameters, which are our senses to touch, hear, see, smell and taste. 

The neurons in our brain create more complicated parameters such as emotions and feelings, from these basic input parameters. And our emotions and feelings, make us act or take decisions which is basically the output of the neural network of our brains. Therefore, there are two layers of computations in this case before making a decision. 

The first layer takes in the five senses as inputs and results in emotions and feelings, which are the inputs to the next layer of computations, where the output is a decision or an action. 

Hence, in this extremely simplistic model of the working of the human brain, we have one input layer, two hidden layers, and one output layer. Of course from our experiences, we all know that the brain is much more complicated than this, but essentially this is how the computations are done in our brain.

Neural Network In Trading: An Example

To understand the working of a neural network in trading, let us consider a simple example, where the OHLCV (Open-High-Low-Close-Volume) values are the input parameters, there is one hidden layer and the output consists of an estimation of the stock price.

Neural Network In Trading Example

In the example taken in the neural network tutorial, there are five input parameters as shown in the diagram. 

The hidden layer consists of 3 neurons and the resultant in the output layer is the estimation for the stock price. 

The 3 neurons in the hidden layer will have different weights for each of the five input parameters and might have different activation functions, which will activate the input parameters according to various combinations of the inputs. 

For example, the first neuron might be looking at the volume and the difference between the Close and the Open price and might be ignoring the High and Low prices. In this case, the weights for High and Low prices will be zero. 

Based on the weights that the model has trained itself to attain, an activation function will be applied to the weighted sum in the neuron, which will result in an output value for that particular neuron. 

Similarly, the other two neurons will result in an output value based on their individual activation functions and weights. Finally, the output value or the estimated value of the stock price will be the sum of the three output values of each neuron.

In the next installment, Devang will discuss how we can train the Artificial Neural Network.

Disclosure: Interactive Brokers

Information posted on IBKR Campus that is provided by third-parties does NOT constitute a recommendation that you should contract for the services of that third party. Third-party participants who contribute to IBKR Campus are independent of Interactive Brokers and Interactive Brokers does not make any representations or warranties concerning the services offered, their past or future performance, or the accuracy of the information provided by the third party. Past performance is no guarantee of future results.

This material is from QuantInsti and is being posted with its permission. The views expressed in this material are solely those of the author and/or QuantInsti and Interactive Brokers is not endorsing or recommending any investment or trading discussed in the material. This material is not and should not be construed as an offer to buy or sell any security. It should not be construed as research or investment advice or a recommendation to buy, sell or hold any security or commodity. This material does not and is not intended to take into account the particular financial conditions, investment objectives or requirements of individual customers. Before acting on this material, you should consider whether it is suitable for your particular circumstances and, as necessary, seek professional advice.