Use The Netflix Algorithm To Beat The NASDAQ: 2 Demo Portfolios

Updated: 2 days ago


Recommendation engines are often used to maximise the revenue of online platforms in all sorts of industries. In this article, we thought it would be interesting to adapt the very popular Netflix prize algorithm 2010 to rank stocks rather than movies and generate portfolios based on iconic investment styles.

1. Overview of the Netflix algorithm

The Netflix prize algorithm uses a collaborative-filtering approach that decides what to show you based on what other people have watched and what you've watched. It starts with a user-movie matrix:

Based on this matrix, we create 2 new matrices, U and V, using a black magic interpolation:


U and V, once found, can be multiplied together to give the affinity any user has towards a particular movie:

This matrix factorisation enables recommendations to be generated for any user, by simply multiplying the user's vector (V) by the movie's matrix (U). In other words, it becomes possible to tailor suggestions for a user, only knowing a couple of the movies they've watched.

2. Adapt the algorithm for stocks rather than movies

Now, what would it take to use this algorithm for stocks?

First, we need "users" or "investor profiles":



We can generate a myriad of these profiles for every financial ratio automatically. Bob will like companies with the highest net margins, whilst Jenna will like companies with the lowest debt to equity ratio, and so on. The output is a matrix that looks like:



The algorithm would fill in the blanks to suggest the stocks to buy for any given user.




3. Generate investor profiles programmatically based on iconic investor styles

Rather than just imagining random virtual profiles like Bob, let's generate them based on iconic investor styles.


The first one is obvious. The "Oracle of Omaha", king of value investing:



We create 100 "variants of Buffet" programmatically with different levels of tolerance for the financial ratios (gradually becoming more and more strict in an already very selective range) in order to infer what stocks our artificial "Warrens" would select among thousands of publicly traded companies. We end up with 100 Buffet profiles (i.e: buffet_1, buffet_2, ..., buffet_100) and the companies each of them have selected, focusing on high margin, low debt, high returns, and low price.



The second one is "Crazy Cathie", the queen of growth in Wall Street:



We create 100 "variants of Wood" with different levels of tolerance for the financial ratios (gradually becoming more and more strict) in order to infer what stocks our artificial "Cathies" would select among thousands of publicly traded companies. We end up with 100 Wood profiles (i.e: wood_1, wood_2, ..., wood_100), having selected top companies with high network effect. Very often, this means: high price, high debt, no dividends, and underestimated growth.


Having generated these profiles and their programmatic tastes using our favourite data provider FMP, we train our machine learning model using LightFM, a Machine Learning library for recommendations.




4. Generate a Buffet portfolio based on programmatic profiles


Now let's use the models we just created. Let's assume that I want to build a portfolio based on the fact that I like Apple as a stock and want the algorithm to recommend some stocks that Buffet would buy, similar in terms of fundamentals to this pick. Using the Warren Buffet recommender we get:


The Neftlix prize algorithm suggests the following "Buffet" portfolio:


4. Generate a "growth" portfolio based on Wood programmatic profiles


Now, let's assume that I want to build a portfolio based on the fact that I like Tesla as a stock and want the algorithm to recommend some stocks that Wood would buy, similar in terms of fundamentals to this pick.




The Neftlix prize algorithm is suggests the following "Wood" portfolio:



5. Conclusion and perspectives

We've generated 2 polar-opposite portfolios using programmatic investor profiles and the Neftlix prize algorithm.

As a test, we've calculated the returns of the 2 portfolios against the NASDAQ (the race horse of stocks indices) from the beginning of the COVID-19 crisis in 2020 to the time of writing:




There are two takeaways for us: - It's time to stop being "cute". Currencies around the world are under attack. It's becoming an absolute priority to perform better than the FED balance sheet. In that toxic environment, we're radicals: avoid diversified ETFs and pick stocks with top fundamentals ("Buffet") or powerful network effects ("Wood").