Predicting the Stock Market with Recurrent Neural Networks
October 22, 2026
Have you ever wondered how you could grow your savings? Many of us have some extra money sitting in our bank accounts. While keeping a financial buffer is important, leaving all your savings in a bank account may not be the best way to build wealth over the long term. Inflation gradually reduces the purchasing power of money, while investing offers the possibility of growing it over time.
For those looking to invest, the stock market is one potential option. However, getting started can feel intimidating. Which stocks should you buy? Which ones should you avoid? When is the right time to invest? Understanding the stock market requires time, research, and at least some knowledge of economics and investing. Even experienced investors struggle to predict how stock prices will move.
Could machine learning help make these decisions a little easier?
That was the question behind our Stock Market Predictor, a program designed to identify potentially promising stocks using historical market data and recurrent neural networks (RNNs). Instead of requiring users to analyze individual companies and market trends themselves, the program aims to provide a data-driven starting point for investment research.
How Does the Stock Market Predictor Work?
The idea behind our program is pretty straightforward: predict how much a stock's price might change over a given period and use that prediction to identify stocks that could be worth investigating further.
To accomplish this, we used a recurrent neural network and trained it on historical stock market data obtained from Yahoo Finance. The model learns patterns in past price movements and uses up-to-date market data to generate predictions about future price changes.
We applied this approach to companies listed on the Helsinki stock market. The result is a list of stocks that the model predicts may increase or decrease in value. This makes it possible to compare companies based on their predicted price movements and investigate which ones appear most promising according to the model.
Putting the Model to the Test
Building a stock market prediction model is only the first step. The more interesting question is whether it actually works.
How accurately can our model predict future stock price movements? Does it identify stocks that subsequently increase in value, or does it struggle to distinguish promising investments from poor ones? And how well does its performance hold up when applied to different companies?
To answer these questions, we evaluated our Stock Market Predictor and examined the results it produced. In the following sections, we will take a closer look at our approach, the predictions generated for the Helsinki stock market, and what the results reveal about the potential of using machine learning for stock market prediction.
Training Process
We tested different model training parameters to find the combination that worked best. The results showed that simpler parameters generally produced the best results. We also compared the model's performance during and after training to ensure that it could work well with new, previously unseen data rather than simply memorizing the training data.
Simulation
To evaluate the application, we simulated its use at different points in the past using shortened versions of the historical dataset. Each simulation used only data available at that point in time, with normalization performed separately for each dataset. This allowed us to examine how the model might have performed in a realistic setting without using future information during training.
The basic simulation covered 30 time intervals, spanning approximately 900 stock market days. At each interval, the application selected the stocks predicted to gain the most value and those predicted to lose the most. We then calculated the resulting profits and losses using actual stock prices over the prediction period.
For simplicity, the simulation assumed equal investment amounts for buying and selling, allowed stocks to be sold without prior ownership, and excluded taxes, transaction costs, and dividends.
Results
The results suggest that the model performed best when selecting just one stock predicted to gain the most value and one predicted to lose the most at each interval. Including more stocks generally brought the average profit closer to zero.
The length of the historical data used for training also affected performance. For predictions targeting 30 stock market days into the future, a sequence length of 150 days performed best among the tested alternatives. Although the model's price predictions were often inaccurate, it appeared capable of identifying the general direction of price movements. The most promising models generally produced positive profits over longer simulation periods, though results varied considerably between intervals.
We also tested longer prediction horizons of 60 and 90 stock market days. These models showed comparable average performance but greater variation. Overall, the 30-day prediction horizon combined with a sequence length of 150 appeared to offer the most reasonable balance of performance and consistency.
Finally, we investigated the influence of individual companies on the results. Two relatively volatile companies appeared to contribute positively to the model's performance. Excluding them from the prediction results reduced average profit margins, although they remained part of the training data.
What Do the Results Tell Us?
Our simulations suggest that recurrent neural networks can identify potentially useful patterns in historical stock prices, but their predictions remain uncertain and profits can vary substantially over time. The results provide an encouraging starting point for further experimentation.