In this article, we train a machine to identify companies with good fundamentals that will perform well on the stock market. We will discover what constitutes a safe debt ratio and net profit margin when picking stocks. Keep reading to find out more about what surprising results we eventually uncovered to invest with ML. Follow us for more!
1. First, we defined precisely what “performant company” means
We assumed a simple rule: if the company’s stock price surged by more than 20% in 5 years (dividend excluded), it is “performant“. This example is with Exxon (NYSE:XOM) and Microsoft (NASDAQ:MSFT):
Of course, this model is very simple but actionable and easy to script to invest with ML.
2. We applied this label on all companies within our dataset
Let’s plot all the American companies based on their net profit margin and debt ratio:
Knowing the price evolution of these stocks between 2015 and 2020, we set a “performant” or “not performant” label for each of them:
As one could expect, it looks like companies with low debt and high enough net profit margin perform better (it’s the blue cloud slightly to the right of the zero). But can we be more accurate and generate a predictive model ?
3. We applied a “k-nearest neighbors” model to generate a predictive map
Let’s zoom on a realistic area of the distribution where most companies would be in:
On this sub-domain, we will generate a million-points mesh with each point of the mesh taking the colour of its (k) closest “neighbors”. This is a famous supervised algorithm checking the colour of the surrounding points (k of them) to deduce the colour of a new one. A simple illustration:
Looking at the 3 items surrounding the mystery item, the algorithm detects that it should become a blue square because 2 blue squares are around against 1 red triangle. Applying this algorithm, we injected a million-point mesh in our initial scatterplot. Then, we ran the simulation for k=100 and k=200. It gave us the following maps (with the same colour code: performing companies in blue, non-performing companies in red):
Here, we identified 2 regions of performance:
4. Conclusions based on the training step
Two conclusions.
(1) It appears we have discovered a “performance tunnel” of companies with an extremely low debt ratio below 20% (performing area 1) regardless of what their net profit margin is. If you want companies that would very likely perform well over time then narrow down your research to positive net profit margins and a debt ratio below 20%
(2) Some companies with impressive net margins (over 22%) seem to perform well even with a moderately high debt (performing area 2). This could mean that they have enough entropy to use this debt to fuel their performance. If you’re after these types of stocks, narrow down to companies with very solid net profit margin above 22%.
Disclaimer: this is Information on how we invest with ML, not advice or recommendations.