A Machine Learning Investing Tool — Entry 1 (Introduction)

This is the first entry of an informal logbook to track my team’s progress in creating an investing process driven by machine learning.

--

Entry 2 (Data Cleaning)

Entry 3 (Feature Selection)

Entry 4 (Testing and Results)

Contents

So what is The Problem?

The Setup

Two Levels of Innovation

Enter: Factor Investing

Initial Assumptions

The Takeaway

Next Steps

So what is The Problem?

“Each team will create and manage a virtual portfolio during the module, and make a presentation on the results at the end of the course, explaining what worked or did not work, and why. The objective is to create a portfolio that will outperform a passive index.

Those were all the instructions we got. So yeah, as far as unstructured projects go, this one is pretty bare-bones. But where there is little guidance, there is much more room to innovate.

The Setup

Going into this project, I wanted to have our team tackle the problem by using machine learning. But the first step of this journey is to iron out exactly how machine learning will be incorporated into the investing process. In other words:

How will we transform the machine learning output into a set of asset weights (that must sum to 100%, by the way) that we can use to build a portfolio?

From here we must come up with some structure. The following might work:

*See (4) below

Trending AI Articles:

1. A noob’s guide to implementing RNN-LSTM using Tensorflow

2. Keras Cheat Sheet: Neural Networks in Python

3. Making a Simple Neural Network

So here’s the plan:

(1) We create N “Profiles”, where each Profile is a portfolio of assets. For best performance, each Profile should have a low correlation with every other Profile.

(2) For each week in our data, we rank each Profile by performance (% return for that week), and teach the algorithm to predict which of the N Profiles will be the best performer each week. This turns our problem into a multi-class classification task.

(3) For each weekly prediction, the algorithm will output a vector of N probabilities (one for each Profile), listing the probability of each Profile being the best performer for the week.

(4) The “Optimal Profile” for each week is thus a weighted-average (weighted by the probabilities in (3), above) of the N Profiles. Remember, each of the N Profiles is just a list of asset weights. As one of my group members put it, this makes the Optimal Profile a “weighting of asset weights”. Don’t worry if that doesn’t make sense yet.

Two Levels of Innovation

From the diagram above, we see that there are two levels at which we, as organic life-forms, can impact the success of this project.

Level 1 — Choosing “Good” Profiles and Input Features. Domain knowledge is king.

Level 2 — Algorithm Selection and Tuning.

In this entry, let’s discuss how we can do the first-half of Level 1 properly:

How can we construct a “good” set of Profiles?

It is crucial that we get this part right. Otherwise, it’s GIGO. The ideal set of Profiles should satisfy the following two Criteria:

Criteria (1) — Each Profile should be relatively uncorrelated with each other. If this happens, then each Profile will shine at different points in time (under different market environments), and will complement each other nicely. Another benefit of this criteria is that, given a large training sample (used as input for the ML algorithm), we will likely see good representation from all Profiles, in the target variable (i.e. “the best portfolio of the week”)

Criteria (2) — Each Profile should be able to perform well under certain conditions, over different periods of time.

So how do we achieve these simultaneously?

Well, if we can characterize each Profile by certain attributes (where the attributes have a low correlation to each other), this would help us fulfill Criteria (1). With two attributes, we can plot each Profile accordingly:

But how do we select these attributes? And by the way, how do we fulfill Criteria (2)?

Enter: Factor Investing

What is Factor Investing?

Some helpful background. Simply put, Factors are attributes of stocks. Factors have shown to drive stock outperformance, over long periods of time. These Style Factors include:

  • Value (low stock price relative to fundamental value)
  • Size (market capitalization)
  • Momentum (trend-following)
  • Quality (stability, boring-ness)
  • Dividend Yield
  • Volatility

Sounds so simple. So what’s the catch?

For starters, each Factor has been cyclical across time (they outperform some times, and underperform during other times). This cyclicality lends itself to the second wrinkle: some Factors are correlated to other Factors. More info on cyclicality and correlation between Factors.

Of these, cyclicality is not a huge issue. In fact, Factor cyclicality helps us satisfy Criteria (2) above. Now what about Factor correlation?

We’re in luck, because according to this research from MSCI, not all Factors are strongly correlated to each other:

MSCI: Deploying Multi-Factor Index Allocations in Institutional Portfolios, December 2013

With that in mind, the next step is to assess feasibility: how easy is it for us to construct Profiles to capture these Style Factor exposures?

  • Value — There are some value-oriented ETFs, but (1) there probably aren’t enough to provide global diversification, and (2) these ETFs likely don’t have enough historical trading data to feed into the ML algorithm.
  • Size There are several market-cap-oriented ETFs across the globe (good diversification), and these likely have plenty of historical trading data.
  • Momentum — Same concerns as the Value Factor.
  • Quality — Same concerns as the Value Factor.
  • Dividend Yield — Same concerns as the Value Factor.
  • Volatility — This is a funny one. On the surface, it suffers from the same concerns as the Value Factor. But if we loosen this Factor a bit and aggregate it into a general “Risk” Factor, we can capture it with a portfolio of industry sector ETFs (sectors of the market are known to have chronically different volatilities) and US Treasury Bond ETFs (which are known as stable, safe investments).

For those of you unconvinced by what we just did (aggregating the Volatility Factor into a more general “Risk” Factor), consider that modern financial markets may be driven by a “Risk ON / Risk OFF” dynamic (a.k.a. “Greed / Fear”), with each of these two mentalities dominating at different points in time (cyclicality). This allows us to meet Criteria (2) of “good” profiles above, while also capturing the diversification benefit of holding safe bonds in addition to equities.

In contrast to the plot above, our Profiles can now be plotted as:

Initial Assumptions

At this stage, our biggest assumptions are:

(1) Style Factors (Size and Volatility, in particular) will continue to meaningfully drive stock performance going forward.

(2) The Size and Volatility factors will continue to not be strongly correlated with each other (correlation = 0.12 in the MSCI chart above).

(3) We will be able to capture the Size and Volatility factors by using our Profiles, such that we can get substantial exposure to these factors.

(4) All the above hold for weekly returns. We are choosing to look at weekly returns because daily returns may be too noisy, and monthly returns will leave us with insufficient data to put in the ML algorithm.

Other assumptions will likely be added in subsequent entries to this log.

The Takeaway

So what have we designed? In essence, this strategy is a factor-timing strategy, where we use a machine learning algorithm to fine-tune our exposure to certain Style Factors (Size and Volatility, in this setup). By doing so, we will hopefully capture the outperformance of these Factors, while shielding ourselves from time periods when one of these Factors underperforms.

A possible advantage of this design is the Two Levels of Innovation, where Level 1 both (a) emphasizes domain knowledge and (b) has a huge potential to drive the success/failure of this strategy. By setting up our process like this, we may be able to avoid the pitfalls of the “Black Box” trap (over-reliance on having powerful algorithms find spurious relationships).

Next Steps

The next entry will describe how we extract, clean, and prepare the data (how fun!).

--

--