Momentum Strategies¶
Building momentum signals with qex.
Basic Momentum¶
Buy winners, sell losers:
Higher returns → higher rank → long position. rank(x) - 0.5 is roughly centred; a book
built with build_book is demeaned exactly, and demean(rank(x)) centres it yourself.
Time-Scale Variations¶
# Short-term (1 week)
rank(returns(5)) - 0.5
# Medium-term (1 month)
rank(returns(20)) - 0.5
# Long-term (6 months)
rank(returns(126)) - 0.5
# Annual (skip recent month to avoid reversal)
rank(delay(returns(252), 20)) - 0.5
Volatility-Adjusted Momentum¶
Sharpe-like signal:
Momentum Acceleration¶
Bet on improving momentum:
Trend-Weighted Momentum¶
Overweight when momentum is trending:
Volume-Adjusted Momentum¶
Weight by unusual volume (recent volume relative to its own norm):
Sector-Neutral Momentum¶
Remove sector effects:
Or rank within sector:
Conditional Momentum¶
Only trade in calm markets:
Multi-Horizon Composite¶
Blend multiple timeframes:
let short = rank(returns(20)) - 0.5,
medium = rank(returns(60)) - 0.5,
long = rank(returns(126)) - 0.5
in 0.2 * short + 0.5 * medium + 0.3 * long
EWMA Momentum¶
Exponentially weighted returns:
Breakout Momentum¶
Distance from highs:
# Proximity to 52-week high
rank(close() / ts_max(close(), 252)) - 0.5
# Days since high (lower = more recent breakout)
rank(-ts_argmax(close(), 252)) - 0.5
Decay-Weighted Momentum¶
Recent returns weighted more:
Beta-Neutral Momentum¶
Momentum books pick up the market's direction: after a rally the winners are the high-beta names. Regress beta out (see Market Beta):