Just another Network site

A simple deep learning model for stock price prediction using TensorFlow

A simple #DeepLearning model for stock price prediction using TensorFlow

  • Having this data at hand, the idea of developing a deep learning model for predicting the SP 500 index based on the 500 constituents prices one minute ago came immediately on my mind.Playing around with the data and building the deep learning model with TensorFlow was fun and so I…
  • # Import datadata = Dimensions of datasetn = data.shape[0]p = data.shape[1]The data was already cleaned and prepared, meaning missing stock and index prices were LOCF’ed (last observation carried forward), so that the file did not contain any missing values.A quick look at the SP time series using pyplot.plot(‘SP500’):Time series plot…
  • We need two placeholders in order to fit our model: X contains the network’s inputs (the stock prices of all SP 500 constituents at time T = t) and Y the network’s outputs (the index value of the SP 500 at time T = t + 1).
  • # Model architecture parametersn_stocks = 500n_neurons_1 = 1024n_neurons_2 = 512n_neurons_3 = 256n_neurons_4 = 128n_target = 1# Layer 1: Variables for hidden weights and biasesW_hidden_1 = n_neurons_1]))bias_hidden_1 = Layer 2: Variables for hidden weights and biasesW_hidden_2 = n_neurons_2]))bias_hidden_2 = Layer 3: Variables for hidden weights and biasesW_hidden_3 = n_neurons_3]))bias_hidden_3 = Layer…
  • Hereby, placeholders (data) and variables (weighs and biases) need to be combined into a system of sequential matrix multiplications.Furthermore, the hidden layers of the network are transformed by activation functions.

For a recent hackathon that we did at STATWORX, some of our team members scraped minutely S&P 500 data from the Google Finance API. The data consisted of index as well as stock prices of the S&P’s…

A simple deep learning model for stock price prediction using TensorFlowFor a recent hackathon that we did at STATWORX, some of our team members scraped minutely SP 500 data from the Google Finance API. The data consisted of index as well as stock prices of the SP’s 500 constituents. Having this data at hand, the idea of developing a deep learning model for predicting the SP 500 index based on the 500 constituents prices one minute ago came immediately on my mind.Playing around with the data and building the deep learning model with TensorFlow was fun and so I decided to write my first Medium.com story: a little TensorFlow tutorial on predicting SP 500 stock prices. What you will read is not an in-depth tutorial, but more a high-level introduction to the important building blocks and concepts of TensorFlow models. The Python code I’ve created is not optimized for efficiency but understandability. The dataset I’ve used can be downloaded from here (40MB).Importing and preparing the dataOur team exported the scraped stock data from our scraping server as a csv file. The dataset contained n = 41266 minutes of data ranging from April to August 2017 on 500 stocks as well as the total SP 500 index price. Index and stocks are arranged in wide format.# Import datadata = Dimensions of datasetn = data.shape[0]p = data.shape[1]The data was already cleaned and prepared, meaning missing stock and index prices were LOCF’ed (last observation carried forward), so that the file did not contain any…

A simple deep learning model for stock price prediction using TensorFlow

Comments are closed, but trackbacks and pingbacks are open.