Volant AI
Published in

Volant AI

Predicting S&P 500 short-term stock prices using a low-cost AI model marketplace

This is a more interactive article where we walk through not only how easy it is to use one of our low-cost ($30–50) AI prediction models but how it performs in a famously difficult problem: stock market prediction. We’ll give a background, do different types of analyses and along the way, demo the use of one of our stock prediction models for an S&P 500 (500 largest companies on stock exchanges in US) company.

As a reminder, at Volant AI (https://volantai.org), we are building the AI model marketplace where anyone can buy/sell high-quality, crowdsourced models faster and cheaper than ever. Check out the models on our marketplace at https://marketplace.volantai.org.

20+ live models on the marketplace. Check it out!

People are unpredictable

https://seekingalpha.com/article/4402481-why-gamestops-stock-price-go-up-explaining-squeeze

Early this year (2021), a group of retail traders banded together and performed a short squeeze. Long story short, they drove the prices of a typically low-value stock (Gamestop) up that certain traders were trying to take advantage of (in the form of a short). There’s plenty of far better articles breaking down the incident and its ramifications, but the point is that the stock market is volatile. It’s difficult to predict human behavior and since stock market trends can be driven by — directly and indirectly — human behavior, it’s incredibly difficult to predict the stock market.

Someone looking to plan their trading strategy can leverage deep learning to view the stock market as a data problem (clean/engineer the data and then train it to predict). There’s aspects of this that are certainly flawed; we don’t even have a concrete understanding of what drives the stock market (https://www.investopedia.com/articles/basics/04/100804.asp). We’re no stock market experts, but a reliable prediction mechanism (like an AI model) can inform your trading strategy and help you maintain your bottom line.

With this being said, let’s walk through one of the models for predicting a FAANG stock!

Building the models

We obtained the Yahoo finance data for the 25 most high volume stocks in the Standard and Poor 500 (S&P 500) — which is an index that tracks the highest volume stocks in the US stock exchange. We then trained a model (for each of the stocks) that takes the previous five-day’s stock market close values and predicts the sixth day.

Why this approach? In the previous Investopedia article, it’s written that there are fundamental factors that drive stock prices that are primarily associated with the company’s performance. It usually encompasses metrics like cash flow per share, expected growth in earnings base and discount rate. These aren’t as relevant in the short run and technical factors like inflation, demographics, liquidity and market sentiment. In terms of short run prediction, a good (base) approach seems to be to have a consecutive day prediction and assume that there is some measure of influence of previous days in the current day (possibly manifesting via market sentiment or trends).

Easy to Buy and Use

Before we dive into predicting and analyzing results of our models, it’s probably worthwhile to show easy it is to buy — and use — the models. It’s pretty straightforward to buy a model and is similar to browsing a traditional sort of catalog on an online marketplace.

Using a model does require the installation of Docker (https://www.docker.com/get-started). Why do you need to install Docker? This article explains why. It’s still not too difficult to do so (and totally worth it if you want to flexibly deploy a model-as-a-server). You can see how easy it is to use a (bought) model below:

Use model from marketplace

Prediction and Analysis

We focused on analyzing the NFLX Close Predictor model which predicts the stock market close values for the Netflix (NFLX) stock. The model works by our inputting a CSV file containing five consecutive days’ values of stock prices and it predicting a day6 value. We used the model in two manners: aggregate prediction and spot prediction. It’s important to note that we focused on the July 23rd to August 5th stock prices. Our model had no view of those stock prices since it was trained on data up til July 17th. The primary metric we used for analysis was something called MAE (the lower the MAE, the better the model performs).

Aggregate Prediction

In aggregate prediction, we started with a specific date (July 23rd) as our starting point. More specifically, our first prediction row was the true stock market value; we inputted July 23rd’s value as day1, July 29th as day5 and we wanted to predict July 30th’s value. We could then compare to July 30th’s true market price and calculate the error. We then fed back and shifted the price values so the new day1 was the true July 24th value, July 30th’s predicted value became day5’s value and we were now trying to predict the August 2nd market price as our day6.

We calculated the MAE as 7.34. Essentially, the model was off by ~7 points for the stock close values. We expect this feedback loop method to be highly error prone, especially as time goes on. When we shifted our input to where all of our feature (day1 to day5) values were predicted by the model, no ground truth market values involved meant more cause for error. The days closest to our ground truth will be less erroneous but as the initial error aggregates and the values drift, the predicted Close values are more and more off.

Spot Prediction

This approach was more in line with the philosophy of the model. We wanted to have short run prediction that would take in a consecutive 5-day sequence of Close values (true recorded NFLX values) and output the day6.

We got the MAE to be around 3.94. This is significantly better than before and, we can see that it was quite close on the two days highlighted before. We’d definitely expect this MAE to increase as we try to predict farther and farther in the future (given the absence of the model’s exposure to newer values), but it does fairly good in the short term barring unforeseen circumstances.

It’s really, really hard…

Years of human existence have clearly demonstrated that the stock market is incredibly hard to predict. There’s surely better models and methods (especially those using ensembles of models) that can perform better. People with far more expertise and understanding of the stock market can — and should — build and sell their models to you on our marketplace.

However, if you’re a retail trader or looking to inform yourself about your portfolio, these S&P 500 stock market prediction models are worth it. Though stocks are notoriously fickle and are driven by many factors — extrinsic and intrinsic — a data-driven AI approach is as good a place to start. Each of our stock prediction models are affordable at $30–50 which means they can inform trading decisions for a fraction of the share price.

The ideal situation would be for our models to be constantly updated. The shorter the time horizon between when you’re trying to predict a ticker value, the less error aggregation and more effective our model will be for your situation.You can, using spot prediction — and some aggregate prediction — get some sense of a stock’s performance on a shorter time horizon and that will be pretty helpful for your trading strategy and protecting your bottom line. We’ll have more long term models where stock values are predicted by those fundamental factor we mentioned earlier.

We’re not super good at predicting the future, but we can put ourselves in a better position to do so. Our stock models help you with that.

Built (or building) a better AI or deep learning model for stock market prediction? You should sign up to sell it on our marketplace!

Keep up-to-date with us and follow our LinkedIn, Twitter and Facebook pages. If you want access to our platform so you can buy or sell AI models, sign up!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store