New York Stock Exchange price prediction

The New York Stock Exchange (NYSE, nicknamed "The Big Board") is an American stock exchange at 11 Wall Street in the Financial District of Lower Manhattan in New York City. It is by far the world's largest stock exchange by market capitalization of its listed companies at 30.1 US dollars trillion as of February 2018. The average daily trading value was approximately 169 billion US dollars in 2013.

ny_stock.jpg

The aim of this project is to predict the share prices of companies listed on the New York Stock Exchange using Python and deep learning.

It is extremely hard to predict the stock market. Stock market prediction is the act of triying to determine the future value of a company stock. Predicting such an unstable market in which many external factors come into play is very difficult. But if you are able to successfully predict the price of a stock, you could gain an incredible amount of profit.

We are going to try to predict the price of Netflix.

1. Choosing the data

The first step was to choose the data. We obtained the data from https://www.kaggle.com/dgawlik/nyse.

This is the most recent possible dataset showing price results up to 2017.

This dataset consists of following files:

2. Choosing the model

Using recurrent neural networks (RNN) in tensorflow.

3. Building the model

We import the different libraries.

We do some settings, as choosing the size of our train, validation and test sets.

We import the dataset.

Creating functions.

Netflix prediction

netflix

We plot the actual stock values for Netflix, prices and volume.

Here we choose the Netflix stock we are interested in and remove the unused values such as symbol and volume.

Then we normalize the data. Normalizing time series data is benefitial when we want to compare multiple time series/stock price trends. After normalization the price will be ranging in an interval between 0 and 1. So normalization is convenient for comparing price trends for multiple stocks in one graph.

It is also very important because Neural networks prefer standardized/normalized input so they can learn faster.

Let's define training and test sets for our model

We plot again the Netflix stock with the normalized prices

We can now construct our model. Let's start our Recurrent Neural Network

A recurrent neural network (RNN) is a class of artificial neural network where connections between nodes form a direct graph along a sequence. This allows it to exhibit temporal dynamic behavior for a time sequence.

We need two placeholders in order to fit our model. X contains the network's inputs and Y the network's outputs

First we set the different parameters to define our RNN. Variables need to be initialized, prior to model training.

We need two placeholders in order to fit our model. X contains the network's inputs and Y the network's outputs

We design the network architecture. The hidden layers of the network are transformed by activation functions. Activation functions are important elements of the network architecture since they introduce non-linearity to the system.

Then we used the Adam optimizer wich is made for improving speed and performance for training a specific model.

At this point the model needs to be trained

Now we want to plot the predictions et zoom it to see what will happen in the future.