# 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: