Neural Network Stock Selector

I’ve been developing this code base for about 6 years – even longer in a casual manner. Over the past 6 months I’ve been upgrading the code base from a very old version of Matlab to Matlab R2017b (4 years old but still reasonably recent).

In a nutshell, the system develops Neural Networks to analyze a large number of stock profiles and then predict the movement of the stock prices over the next year – so it’s forecasting for a year time period. The key component is the one in which the Neural Networks carefully select stocks that are highly likely to surge in the upcoming year.

During the code upgrade process, I periodically run full end-to-end tests to make sure the system architecture integrity has been preserved. Below are the results from a test case run this morning. The Neural Network system analyzes a list of companies over 10 years and makes predictions for each year. Part of the process is to “team” the Neural Networks – that is that a stock only makes it on a list if at least a specified number of Neural Networks have selected it. So for a teaming number of 20, the system would show the companies that were selected by at least 20 Neural Networks.

Below is a set of plots from this test run (the forecast time period is 2008 through 2017) – a teaming number of 20 was selected – the companies were used in simulated purchases and sales of the selected stocks.

The vertical yellow bar was added in to highlight the teaming number 20 performance results. The performance of the system is shown below in a table format.

The Neural Network system abstained from selecting any stocks in 2008, 2014, and 2015.  For the other years the team of 20 selected various stocks.  The only bad year was 2017 – the Neural Networks selected two stocks that were sold at an automatic -10% loss limit. The average Return-On-Investment (ROI) for the Dow Jones Industrial Average (DJIA) was 7.9%. The average ROI for the Neural Network system was 43.5%.

The bottom line is that over 10 years, the Neural Network system outperformed the DJIA by a factor of 5.5.  Below is the result of a short script that computed an initial investment of $100 for the DJIA and the Neural Network system – it then adds in the return on investment for each year.

After 5 years, the Neural Network would have put the investor ahead by a factor of 6.1 over the DJIA and by the end of 10 years, the investor would have made 12.2 times the amount by using the Neural Network system.

Below is an example of the selection output for a teaming number of 20 for the year 2016. The aggregate return on investment was 97.6%.

The stock chart profiles for the selected companies, LEE and MTZ, are shown below. The forecast period was 2016.

The current objective is to get the code upgrade finished and then configure it to test for weekly predictions. That is that the system will select certain stocks that should do well over the next week (purchased on Monday and sold on Friday or before). I’ll be running real-time tests – that is that predictions will be published on my YouTube channel so that an absolute time-stamp is attached to the predictions. Then we’ll see how the selected stocks fair.

Published by Joys and Sorrows of Coding

Originally my degree was in Aerospace Engineering but I started coding in school and was hooked. In those days it was FORTRAN and reverse Polish notation on my hand-held HP 41-CV computer. Later I learned C, Pascal, Matlab, Java, C++, HTML and Python. Now I'm learning Android (Java) with Android Studio. The main IDEs that I use are NetBeans, IntelliJ IDEA, and Android Studio.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: