Recurrent Neural Networks and the Stock Market

I recently had someone reach out to me for advice on using recurrent neural networks to help them make stock picks. Although this idea has some intuitive appeal, I ultimately think the argument is specious. I'll first discuss the merits and then cover why I advised this person to spend their time elsewhere.

A recurrent neural network (RNN) can be used in a way that blurs the lines between supervised and unsupervised learning. Let's assume you take measurements of the market price of a stock at 15 minute intervals and collect this data for a few days. Given this time series, you'd obviously like to know what prices will be in the future. Pick some fixed window of observations, perhaps a window of size 10. Use the first 10 price observations as training data, and use the eleventh as the objective of your prediction. Next, shift this window over by one, covering times 2-11, and use 12 as the objective. In this way, you can build up a training set that has labels, but is (debatably) not exactly supervised learning since the data didn't have to be labeled.

Technically, this approach can be done with a variety of different machine learning approaches, and I imagine I would find examples of this if I did more research about methodologies in finance. RNNs are an interesting approach for all the reasons deep learning is appealing. In time series approaches, a good deal of effort goes into preparing and normalizing one's data. Denoising, deseasoning, and a variety of other techniques are often employed to prepare your data in a way that's conducive to better performance by whatever method you intend to apply. While RNNs will certainly benefit from some of these preprocessing steps, conceptually, we expect them to learn representations of the time series as part of the training process.

Embedded in this idea is a belief that the stock ticker has some sort of periodic pattern. One hopes that the RNN would learn these patterns and be able to predict future prices based on the information content of what was learned. The RNN architecture allows for cycles in neurons, allowing them to have a form of memory not available in other architecture. This makes it possible for them to recognize temporal effects.

If we imagine that the process which generates the stock price (broadly, the market) has any sort of state, then the RNN is expected to learn to recognize the states and learn the transition function describing how the process changes between states. An example of a "state" might be the market entering a cautious period in which trade volume decreases and variance in price contracts. In all likelihood, any state we might ascribe is probably a more complex phenomenon, but this analogy may be helpful.

Recent breakthroughs in natural language processing, speech signal processing, and a variety of other difficult problems all lend support to the idea that RNN are a smart choice for time series problems. Further, if I owned a large money management, I would definitely be insisting that my team be experimenting with many methods including RNNs in pursuit of smarter trading strategies.

Yet my advice to this individual was essentially to give up. Why?

I have a general arguement against this. It's not necessarily specific to RNNs, but below are my thoughts.

Let's assume there is some pattern in a stock price. Perhaps you find a stock which consistently surges in value every Wednesday, and falls back to it's original price on Thursday. First, realize that with so many stocks available, you are going to be able to cherry pick this phenomenon somewhere. It's going to occur by chance. But as they say, past performance is not indicative of future performance.

Let's play along and assume that you've found the pattern described above and it's a real phenomenon. You would want to buy as much stock as possible around the close on Tuesday, ride the wave to the top Wednesday, and sell before the Thursday fall arrives. If you do this and you profit from it, a rational person would want to push their luck. Buy as much of that stock as you can while low, and sell while high.

Many of us think of the market as having these interesting elastic properties. There is always someone willing to buy or sell any stock at any time. This is essentially true, partially because of so many players and partially because of design. Most stocks have an assigned market maker (not discussed here) who essentially gets certain benefits by guarenteeing they will always be willing to trade on a particular stock.

Few of us are able to buy enough stock to influence the market. If you found this nice Wednesday bump and exploited it to the furthest, however, you're eventually going to start moving the market. Your trick is like a special button you can press that instantly gives you money. If I encounter such a button, I'm going to push it as fast and frequently as I can. I'm going to explore inventing a special button pressing machine to maximize my yield. If I'm consistently making profit, then I can afford to do this. At some point, I'm going to be trying to buy so much stock on Tuesday night that I drive the price up because no one holding the stock is willing to trade it at a low price. I first buy up all the stock offered from people at the current market rate. When those traders supply is exhausted, I have to see who is next in line. This person might only want one penny more. Fine. I buy all their stock and move on to the person behind them in line willing to sell.

As I move my way through traders, the price is going to go up until such time as it's no longer advantageous for me to exploit my knowledge. When this happens, I've extracted the maximum value from the market. As this happens, my influence on the price of the stock is destructive to information in the stock. That pattern of Wednesday peak and Thursday trough will disappear.

Thus, any non-spurious pattern available in a stock ticker is going to be erased when someone notices and exploits it. Your only possible advantage is to have secret information about a pattern that no one else was able to see. While it is entirely plausible that you are a genius investor that was able to detect something useful which the entire financial industry failed to notice, that seems a bit presumptuous. There exist people with my aptitude or better who got educated specifically in topics relevant to the stock market who have spent 40 hours per week for their entire careers studying the market. Certainly some of those individuals are more capable than I am at finding and exploiting these patterns, not to mention the chances they have the resources of a large bank behind them.

If you want to engage in algorithmic trading for fun, go for it! If you want to engage for profit, you're going to need to find a way to come to terms with the essentially arrogant position you'll have to assume - that you're smarter, luckier, or more observant than everyone else.

Ok, so you're a humble person. But maybe the RNN you constructed could turn out to be smarter than everyone else. Possibly. If you're a deep learning researcher, it would not surprise me if you found an algorithmic approach that had some advantage, or a hardware solution which allowed for cheaper/faster computation. If so, start a hedge fund immediately. But in lieu of any strategic advantage, other players in the market have access to all the same tools and techniques you do. They may differ by the random seed the start with, but by and large, they're going to arrive at the same models you are trying to create.

This argument and several other perspectives unrelated to this have made me, as an investor, someone predominantly interested in buying index funds only. I may dabble here and there in other things. I'm especially excited about "creative investments", like investments made in companies for which I'm an advisor, but this is a different type of investment altogether.

Lastly, because I so often hear this disclaimer, I think I should echo it: I am not a financial manager and this article is not formal financial advice. Consult a fiduciary financial advisor before taking any action with your own investments.