Skip to content

dazhili398-debug/Momentum-Factor-Research

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Momentum Factor Research with Alphalens

This project reproduces and extends a momentum factor research workflow based on the Quantopian Alphalens framework.

Since Quantopian has been discontinued, the original workflow is no longer directly executable. In this project, the factor construction pipeline is reimplemented using Yahoo Finance market data, pandas rolling-window calculations, and the Alphalens-reloaded library.

The objective of this project is to reproduce the original momentum factor evaluation workflow and compare multiple momentum factor constructions under a unified evaluation framework.


Project Overview

This project implements and evaluates the following momentum factors:

  • Simple Momentum
  • Regression Momentum
  • Regression Momentum × R²
  • Volatility-adjusted Momentum
  • 12–1 Momentum
  • EWMA Momentum

Each factor is evaluated using Alphalens to analyze its predictive power, portfolio performance, and factor stability.


Methodology

Data Source

  • Yahoo Finance (yfinance)
  • S&P 500 historical daily prices

Factor Construction

The following momentum factors are implemented:

Factor Description
Simple Momentum Past 12-month cumulative return
Regression Momentum Linear regression slope of log prices
Regression Momentum × R² Annualized regression slope weighted by R²
Volatility-adjusted Momentum Momentum normalized by historical volatility
12–1 Momentum Excludes the most recent month to reduce short-term reversal
EWMA Momentum Momentum based on exponentially weighted returns

Evaluation Metrics

Each factor is evaluated using Alphalens factor tear sheets, including:

  • Long–Short Quantile Return Spread
  • Information Coefficient (IC)
  • IC t-statistic
  • Mean Quantile Turnover
  • Rank Autocorrelation

Results Summary

Factor 10D Spread 10D IC Mean t-stat 10D Mean Turnover Notes
Simple Momentum 4.743 0.053 4.702 0.171 Baseline
Regression Momentum 5.555 0.064 5.831 0.074 Strongest IC
Regression Momentum × R² 1.913 0.050 4.697 0.084 Penalizes noisy trends
Volatility-adjusted Momentum 3.810 -0.008 -0.691 0.173 Risk-adjusted momentum
12–1 Momentum 1.479 0.053 4.876 0.164 Classical momentum
EWMA Momentum 4.407 0.024 2.386 0.203 Recent prices weighted more

Key Findings

  • Successfully reproduced the original Alphalens momentum factor evaluation workflow without relying on the deprecated Quantopian platform.
  • Regression Momentum achieved the strongest predictive performance among the reproduced momentum factors.
  • Additional momentum factor constructions were implemented to compare different definitions of momentum.
  • The comparison demonstrates how different factor construction methods influence predictive power, portfolio turnover, and factor stability.

Understanding the Evaluation Metrics

Alphalens evaluates factor quality from several different perspectives.

Quantile Statistics

Stocks are ranked by their factor values and divided into five equally sized quantiles.

  • Top Quantile (Q5): Stocks with the highest factor values.
  • Bottom Quantile (Q1): Stocks with the lowest factor values.
  • Quantiles 2–4: Intermediate groups sorted by factor value.

If the factor is effective, stocks in the Top Quantile are expected to outperform those in the Bottom Quantile over future holding periods.

The figure below shows the distribution of factor values across the five quantiles.

Quantile Statistics

Long–Short Spread

The Long–Short Spread measures the performance difference between the highest-ranked and lowest-ranked portfolios.

Spread = Return(Q5) − Return(Q1)

A larger positive spread indicates stronger factor predictive power.

Performance

Information Coefficient (IC)

The Information Coefficient measures the correlation between today's factor ranking and future stock returns.

  • IC > 0 indicates that higher-ranked stocks tend to generate higher future returns.
  • Larger IC values imply stronger predictive ability.

IC Analysis

IC t-statistic

The IC t-statistic measures whether the Information Coefficient is statistically significant.

Generally,

  • t-stat > 2 indicates statistically significant predictive power.

Mean Quantile Turnover

Turnover measures how frequently stocks move in or out of the same quantile over time.

  • Lower turnover indicates a more stable factor.
  • Higher turnover implies more frequent portfolio rebalancing and potentially higher transaction costs.

Rank Autocorrelation

Rank Autocorrelation measures how stable the factor rankings remain over consecutive periods.

  • Values close to 1 indicate highly stable rankings.
  • Lower values indicate that factor rankings change rapidly over time.

Comparison of Momentum Factors

Six momentum factor definitions were compared using identical Alphalens evaluation metrics.

Comparison


My Contributions

Compared with the original workflow, this project includes the following contributions:

  • Reimplemented the original Quantopian workflow using Yahoo Finance data.
  • Replaced deprecated Quantopian APIs with pandas rolling-window implementations.
  • Reproduced the original Alphalens factor evaluation pipeline.
  • Implemented and evaluated additional momentum factors:
    • Volatility-adjusted Momentum
    • 12–1 Momentum
    • EWMA Momentum
  • Compared multiple momentum factor constructions under a unified evaluation framework.

Project Structure

Momentum-Factor-Research/
│
├── notebooks/
│   └── Momentum_Factor_Research.ipynb
│
├── figures/
│
├── data/
│
├── README.md
├── requirements.txt
└── .gitignore

Installation

pip install -r requirements.txt

Usage

Run the notebook:

jupyter notebook notebooks/Momentum_Factor_Research.ipynb

or open the notebook directly in VS Code.


Original Project

This project is inspired by the original Alphalens project developed by Quantopian.

Original Repository:

https://github.com/quantopian/alphalens

License:

Apache License 2.0


Acknowledgements

The original Alphalens project provides the factor evaluation framework that inspired this work.

Since Quantopian has been discontinued, this repository provides an independent implementation using Yahoo Finance data and pandas rolling-window calculations.

All additional momentum factor implementations, comparative experiments, documentation, and project organization were independently developed in this repository.

About

Momentum factor research using Alphalens and Yahoo Finance

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors