Is AI trading reliable? Can AI predict stocks?
I came across an article Stock Price Prediction With LSTMs on Hacker News. I like Hacker News as it has a large and generally very smart audience; the articles there are often very interesting. This article was upvoted to appear on the front page of Hacker News, which was not easy due to the voting system.
Naturally, I was very intrigued by the title as I have been using LSTM for various applications in trading algorithms for a while. However, pure price prediction from the price series alone is hard. The article presents the following chart on its front page:
The moment you see this you can’t help getting excited, right? However, over the years I’ve learned the following mantra, sometimes the hard way:
When things look too good to be true, something’s wrong.
Luckily, the authors point to their Jupyter notebook on Github, which can be found here. After cloning the notebook I looked at the code and in a nutshell, ANNs (Artificial Neural Networks) were applied to the past time series and a 1-day forward prediction is made for next day’s price.
Welcome to the intelligent, money-printing machine! What could possibly go wrong with that? Are things really too good to be true?
So, let’s look at this a bit more closely. The author uses various types of machine learning algorithms such as LSTM, BiLSTM and GRU and they show slightly different results. But let’s not be too concerned with the details. For simplicity, I just picked the results of the last one.
The predicted price matches the out-of-sample series very closely, which seems pretty amazing at first. However, let’s look at the returns of both the original and predicted out-of-sample prices.