How my AI-powered stock recommendations performed in the past year
How I leveraged AI to enhance my investment strategy and how you can do the same
I have previously published different articles about how I, enhanced by generative AI, have written algorithms in Python to optimize decision-making when engaging in investment activities (you can find the articles at the end of this article).
But how do the AI-generated algorithms actually perform? And how can I evaluate their outcome?
As highlighted in the article “How I built a stock recommendation algorithm using ChatGPT — and how you could do it” I present an algorithm that through 4 different technical indicators gives a recommendation that can be either ‘Buy’, ‘Sell’ or ‘Hold’.
But how reliable are these recommendations? One way to test that is to follow stocks with buy signals over time. So, that’s what I’ve done. Let’s take a deep dive into how:
At the beginning of 2023, I executed the algorithm with just 100 stock tickers. I printed the output in a CSV file to examine the data more carefully. This led to the following:
Afterwards, I simply filtered the table to only those with ‘Buy’ signals which resulted in the following 7 stock tickers:
Thus, I had a list of 7 companies that, based on the 4 technical indicators, indicated ‘Buy’ signals. If you’re not familiar with the stock tickers the companies' full names are:
AAPL: Apple
AXP: American Express Company
CCJ: Cameco Cooperation
CRM: Salesforce
DIS: The Walt Disney Company
DKNG: DraftKings Inc.
DOW: Dow Inc.
Then, I simply waited and tracked the different stock prices over time until today (12. October 2023). I decided to create an overview in the data visualization tool Microsoft Power-BI.
But before that, I needed to get data in relation to the company's historical stock prices starting from the day I executed the algorithm (31. January 2023). Thus, I took advantage of the API that Financial Modelling Prep is offering. Financial Modelling Prep offers almost every financial aspect that you can imagine — from financial statements to insider trading. And more relevant in this occasion: Historical data.
I went through their documentation and saw that historical data could be extracted through this endpoint: https://financialmodelingprep.com/api/v3/historical-price-full/{INSERT_STOCK_TICKER}.
Then, I simply made a direct connection from Power-BI to the endpoint from Financial Modelling Prep and made a data model in Power-BI.
I then uploaded the CSV file consisting of the 100 stock tickers that went through the algorithm, and made a one-to-many relationship between the two tables:
Then, I could start experimenting in Power-BI.
My approach was quite simple: To measure the change in price from the start date (when I executed the algorithm) (31–01–2023) until today’s date (12–10–2023).
That led to this overview (It might seem overly complex at first so let’s break it down slowly):
So what do we see in the overview?
Firstly, at the bottom in the left corner, we have a filter that filters out all the companies with buy signals. That results in the list right above it and is essentially the same as the Excel screenshots we saw earlier.
At the top of the Power-BI report, we have some interesting KPIs. These include:
Closing price 31–01–2023: A measure that shows the closing price of each stock at the start date.
Closing price 12–10–2023: A measure that shows the closing price of each stock at the end date.
Difference in USD: Difference between closing price start date and closing price end date in USD.
Difference in %: Difference between closing price start date and closing price end date in percentage.
S&P500 difference in %: Difference between closing price start date and closing price end date in percentage (it shows empty now, but we’ll get back to that later).
In the middle of the report, we have a graph consisting of all the different 7 companies with their stock prices from the start date until the end date.
So, what are the insights?
Well, firstly we can see that the accumulated closing price on the start date was around 698 USD and around 738 USD at the end date. This gives an accumulated growth across all the 7 stocks of 5.71%.
Let’s try to take a look at specific stocks:
In the screenshot above, we take a closer look at DKNG (DraftKings) which has experienced incredible growth since the beginning of the year (96.53%!!!).
This is by far the stock that has seen the highest growth during the time period. Let’s compare to the rest of the stocks:
In the screenshot above we see the closing prices of each stock during the time period, as well as the difference in price in percentage. 4/7 stocks have performed really well, while the story is a bit different for the last 3 as seen in the table.
So, let’s say we invested in the companies when we first executed the algorithm back in January. Let’s imagine we bought 10 stocks in each firm at the closing price of 31–01–2023. This would look as follows:
In this overly simplified example, we can follow how a total investment of 6.980,30 USD made across the 7 companies would have made us a total of 7.379,10 USD which is an increase of 5.71% during 9 months.
It’s not that bad, is it?
So can we just label the AI-powered algorithm to be ‘good’ since it gave us a profit of 5.71%? I wouldn’t say so.
One way to evaluate whether or not the stocks provided by the AI-powered algorithm is to compare their accumulated growth with the market growth during the same time period.
Thus, I have included the S&P 500 representing the market:
As we can see in this picture (and more specifically in the upper right corner) the market (S&P 500 in this example) has actually outperformed the stocks provided by the AI-powered algorithm with a total percentage change of 6.69%.
So let’s imagine we’d invested the same amount (6.980,30 USD) in S&P500 instead. That would look somewhat like the following:
So, we look at a total profit of 466,75 USD compared to 398,80 USD if investing in the S&P 500 during the same time period.
Let’s take a complete look at the fictional investment:
Thus, by investing in the 7 AI-powered stocks, we wouldn’t beat the market. The AI-powered stocks fall short at about a 1% lower growth compared to the market.
Let’s try taking a more in-depth look at how the changes in percentages have looked during the time period:
What we see in the picture above is a visualization of the growth in percentage of the AI-provided stocks (blue graph) compared to the S&P 500 (yellow graph).
The visualization captures how much our fictional investment would have increased/decreased during the time period.
Interestingly, we see that the AI-provided stocks actually follow the trends in the market and actually beat the market quite significantly up until August 2023.
Insights
So what are the insights and key points we can learn from?
- The AI-provided stocks actually gave us a profit, increasing by 5.71% during the time period.
- The AI-provided stocks provided us with 7 companies that I normally wouldn’t consider investing in / didn’t know about (apart from Apple and Salesforce). It’s especially worth highlighting that it provided us with DraftKings whose stock price grew 96.53% during the time period.
- The AI-provided stocks didn’t beat the market during the time period (5.71% vs. 6.69%)
I think that the most important key insight is that the AI-powered algorithm is not a standalone method to use in investment activities. It cannot, and should not, be the only tool you are basing your decision-making upon.
However, I think that it definitely can enhance your decision-making when buying stocks — but you certainly need other tools and your own rational judgment power to accompany it.
Say that we instead of just “investing” in the 7 AI-provided stocks actually did some more research about these companies. How is their financial health? What products are they going to launch? What is the demand for their products?
Conducting more comprehensive research might have led to only picking the companies that actually saw positive growth in their stock prices.
Link to related articles: