Thrifting Alpha

Revitalizing Tired Alpha Factors Using Ensemble Learning

Quantopian

Max Margenot

Lead - Data Science/Academia

This presentation is for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation for any security; nor does it constitute an offer to provide investment advisory or other services by Quantopian, Inc. ("Quantopian"). Nothing contained herein constitutes investment advice or offers any opinion with respect to the suitability of any security, and any views expressed herein should not be taken as advice to buy, sell, or hold any security or as an endorsement of any security or company. In preparing the information contained herein, Quantopian, Inc. has not taken into account the investment needs, objectives, and financial circumstances of any particular investor. Any views expressed and data illustrated herein were prepared based upon information, believed to be reliable, available to Quantopian, Inc. at the time of publication. Quantopian makes no guarantees as to their accuracy or completeness. All information is subject to change and may quickly become unreliable for various reasons, including changes in market conditions or economic circumstances.

What is an Alpha Factor?¶

  • Also known as a Risk Factor
  • Alternative risk premium

Popularity of Factor Models¶

  • "Smart Beta"
  • Diversify with specific premia
  • Analyze risk
  • Increase returns
  • 87% of institutional investors incorporating factors into investment process*
  • 67% of into risk management process*
  • 53% of into investment strategies*

*"The rise of factor investing." BlackRock. 7 Apr. 2017

Constructing a Factor Model¶

  • CAPM
$$ r_p = \alpha + \beta_{m} r_{m} $$
  • Fama-French Factors
$$ r_p = \alpha + \beta_{m} r_{m} + \beta_{hml} r_{hml} + \beta_{smb} r_{smb} $$
  • Alternative Factors
$$ r_p = \alpha + \beta_0 r_0 + \cdots + \beta_n r_n $$

Using a Factor Model¶

  • A few different ways to do this, once you have decided on your factors
  • Compute exposures to your factor
  • Use the exposures to create your portfolio

Main Factors¶

  • Value
  • Momentum
  • Quality
  • Volatility
  • Growth

The Method¶

  • Long-short Equity
    • Rank all securities in your universe from lowest factor exposure to highest
    • Go long on the top percentile
    • Go short on the bottom percentile

The Universe¶

  • Sufficient liquidity
    • No "hard-to-trade" securities
In [ ]:
universe = QTradableStocksUS()

The Point¶

  • Predicting prices is hard
  • Trying to capture the relative value of the long and short baskets
  • Assuming that expected return of each security in the universe in proportional to factor value

Example Factor: Momentum¶

In [ ]:
class Advanced_Momentum(CustomFactor):
        """ Momentum factor """
        inputs = [USEquityPricing.close,
                  Returns(window_length=126)]
        window_length = 252

        def compute(self, today, assets, out, prices, returns):
            out[:] = ((prices[-21] - prices[-252])/prices[-252] -
                      (prices[-1] - prices[-21])/prices[-21]) / np.nanstd(returns, axis=0)

Example Factor: Momentum¶

Momentum Factor

Example Factor: Momentum¶

Momentum Factor

Example Factor: Momentum¶

Momentum Factor

Other Factors in the Model¶

Other Factors

Workflow¶

Quant Equity Workflow

Factor Aggregation¶

  • Factors can be seen as individual constructed assets
  • We can combine many to create a mega-factor
  • Weighting scheme between factors is up to us

Dynamic vs. Static Aggregation Methods¶

  • Static: Predetermined aggregate factor weighting
  • Dynamic: Changing weights based on their own performance

Static Equal-Weighted Factor Portfolio¶

  • Take all factors
  • Standardize them
  • Add them together

Static Equal-Weighted Factor Portfolio¶

Equal-weighted Portfolio

Static Equal-Weighted Factor Portfolio¶

Equal-weighted Portfolio

Static Equal-Weighted Factor Portfolio¶

Equal-weighted Portfolio

Ensemble Learning¶

  • Obtain better predictive performance by aggregating many learning algorithms
  • Very difficult to find a good trading algorithm
  • Combining "meh" stuff into "okay" stuff

Alpha Factors as Classifiers¶

  • We can reinterpret an alpha factor as a classifier
  • Relative value, classified as going up or going down based on predictor
    • High factor values indicate that we expect the value to go up
    • Low factor values indicate that we expect the value to go down
  • Truncate these into a classification problem.

AdaBoost (Adaptive Boosting)¶

$$ H(x) = sign\left(\sum_{t=1}^T \alpha_t h_t(x)\right) $$
  • where each $h_t(x)$ is the output of a weak classifier and $\alpha_t$ is its weight
  • Linear combination of classifiers inside a non-linear function

Implementation¶

  • Mask factors into classifiers
  • Assume these factors are predictive over a month and predict returns 20 days into the future
  • Re-weight individual factors in aggregate based on performance
  • Profit?

Dynamically-Weighted Signal with AdaBoost¶

  • Build signal in research
    • scikit-learn AdaBoostClassifier
  • 50/50 train/test split

Testing the Signal¶

AdaBoost Accuracy

AdaBoost Accuracy

Feature Importances¶

AdaBoost Features

Dynamically-Weighted Signal with AdaBoost¶

Equal-weighted Portfolio

Dynamically-Weighted Signal with AdaBoost¶

Equal-weighted Portfolio

Dynamically-Weighted Signal with AdaBoost¶

Equal-weighted Portfolio

Market Impact¶

  • It is not enough to find a signal
    • Have to check if it is viable
  • Take into account commissions costs
  • Take into account slippage costs

Boosted factor in the backtester

A Potential Culprit¶

Boosted factor in the backtester

Limitations of Model¶

  • Garbage in, garbage out
    • Passing in better factors should ideally improve performance
  • AdaBoost is sensitive to noisy data and outliers
    • Financial data is ugly
    • A different ensemble classifier might improve performance
  • Maybe just more weak classifiers

Limitations of Platform¶

  • Limited training window for ML classifier
  • Limited backtest window
Twitter

@clean_utensils

Github

@mmargenot

Quantopian

max@quantopian.com

This presentation is for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation for any security; nor does it constitute an offer to provide investment advisory or other services by Quantopian, Inc. ("Quantopian"). Nothing contained herein constitutes investment advice or offers any opinion with respect to the suitability of any security, and any views expressed herein should not be taken as advice to buy, sell, or hold any security or as an endorsement of any security or company. In preparing the information contained herein, Quantopian, Inc. has not taken into account the investment needs, objectives, and financial circumstances of any particular investor. Any views expressed and data illustrated herein were prepared based upon information, believed to be reliable, available to Quantopian, Inc. at the time of publication. Quantopian makes no guarantees as to their accuracy or completeness. All information is subject to change and may quickly become unreliable for various reasons, including changes in market conditions or economic circumstances.