Quant notes · 01 · interactive

Time-series momentum

Time-series momentum is a rule that holds a long position in an instrument whose return over a trailing window is positive and a short position when it is negative. This page states the rule, the mechanism proposed for it, the formulas, the effect of the lookback length, the related trend signals, and the published evidence. Labs use simulated series.

All series on this page are simulated so the "true" answer is known. Nothing here is market data or a performance claim.

1 · Definition

Look at where the price is today compared with where it was L days ago. If it is higher, hold a long position (you profit if it keeps rising). If it is lower, hold a short position (you profit if it keeps falling). Check again tomorrow. That is the whole rule. L is called the lookback.

Nothing in it predicts how much the market will move, or when it will turn. It only bets that whatever direction the last few months had will, on average, carry on a little longer.

Worked example.Gold is at 4,000 today and was at 3,500 twelve months ago. Higher, so be long. Bitcoin is at 80,000 today and was at 95,000 twelve months ago. Lower, so be short. Tomorrow, repeat with tomorrow's prices.

Lab A · Watch the rule trade a simulated market

simulated · not market data

The top chart is a made-up price with five periods: a rise, a sideways chop, a sudden crash, a fall, and a recovery. The background colour is what the rule does: green = long, red = short. The bottom chart is the running profit of following the rule, next to simply buying and holding.

simulated pricerule is longrule is shorttrend rule, running profitbuy and hold, running profit
–times the rule changed its mind
–trend rule, total profit (% of starting money)
–buy and hold, total profit
–trend rule, worst peak-to-trough fall
Four things to try. (1) Set the lookback to 10 days. The rule flips constantly in the sideways patch and pays a cost each time. (2) Set it to 200. It is calm, but it has no opinion for the first 200 days and reacts late: look how long it stays long after the crash begins. (3) Set "how strongly the market trends" to 0. Now the market is a pure coin toss with no trends in it, and the rule has nothing to catch; whatever profit you see is luck of the seed. (4) Move the seed with everything else fixed. The best lookback moves with it. Remember that for section 4.

2 · Mechanism

A market that reacted perfectly to news would jump straight to the new fair price and stop. Trends exist because people do not react like that. Click each stage.

Schematic, not data: the shape of one trend as the sources describe it, from the news to the reversal.

There is also a second, less behavioural reason in the 2012 paper: using positioning data from the US futures regulator, Moskowitz, Ooi and Pedersen find that speculators (who tend to follow trends) make money from the strategy, and hedgers (producers and consumers who want to offload price risk) pay for it. Part of the trend premium is a fee for providing that insurance.

3 · Formulas

signalt = sign( PtPt−L − 1 )

Today's price divided by the price L days ago, minus one, is the return over the lookback. The sign function throws away the size and keeps only +1 (it rose) or −1 (it fell). That ±1 is the whole opinion of the rule.

positiont = signalt · σtargetσt

The ±1 is then scaled by the risk you want divided by the risk the market is currently giving you. σt is the EWMA volatility from the EWMA note (02). This is what lets gold at 18% volatility and bitcoin at 64% sit in the same book: bitcoin gets roughly a quarter of the position size, so each contributes the same expected risk.

rTSMOMt,t+1 = sign(rt−12,t) · 40%σt−1 · rt,t+1

The same thing as the paper writes it (Moskowitz, Ooi and Pedersen 2012, eq. 5): next month's strategy return is the sign of the last 12 months' return, scaled to 40% volatility, times next month's market return. Note σt−1: the volatility used for sizing is from before the month being traded. The 40% is a presentational choice; the paper calls it inconsequential.

4 · Lookback selection

Short lookbacks catch turns early but flip on every wobble and pay costs each time. Long lookbacks are calm but late. Nobody knows the "right" L; the papers use 1, 3 and 12 months and average them precisely so they do not have to choose.

Lab B · Every lookback at once, and why you must not pick the winner

simulated · not market data

This runs the rule for every lookback from 5 to 200 days on the same simulated market as Lab A and plots the total profit of each. The highest point looks like "the best lookback". Then move the seed.

–"best" lookback for this seed (days)
–its total profit
–profit of the median lookback
–share of lookbacks that made money
The lesson.Each seed is a different random history with the same underlying trend strength. The peak jumps around from seed to seed: it is the noise of that one history, not a property of the rule. If you pick the best lookback on your real data, you are fitting to noise you will never see again. The honest numbers are the ones that stay true across seeds: with trend strength above zero, most lookbacks make money (the "share" box), and the middle of the curve is stable. That is why the papers average several lookbacks, and why the project plan says to test "nearby parameters" and to blend 63/126/252 days rather than crown one.

5 · Trend signals

"Compare today with L days ago" is one way to ask "is it trending?". There are others, and they mostly agree. Click any box. The project's signals.py already has the first four.

6 · Evidence

Moskowitz, Ooi & Pedersen (2012)
  • 58 futures markets: 24 commodities, 12 currency pairs, 9 equity indices, 13 bond futures.
  • Rule: sign of the past 12-month return, held one month, each position scaled to 40% volatility. Strategy evaluated 1985–2009.
  • A diversified portfolio of these earns "a Sharpe ratio greater than one on an annual basis", gross of trading costs. Out of sample on 1966–1985: Sharpe 1.1.
  • The effect "persists for about a year and then partially reverses over longer horizons."
  • Performs best in extreme markets, both up and down.
Hurst, Ooi & Pedersen (2017)
  • 67 markets, monthly data, January 1880 to December 2016.
  • Rule: an equal-weighted mix of 1-, 3- and 12-month time-series momentum.
  • Trend following "has performed well in each decade for more than a century."
  • Performed best in large equity bull and bear markets; positive in 8 of the 10 largest drawdowns of a 60/40 stock–bond portfolio.
What that does not say.Neither paper includes bitcoin, which did not exist for most of the sample. Gold futures are in both. The headline Sharpe ratios are for a portfolio of dozens of markets; a single market's trend rule is far weaker (Hurst et al. report an average of roughly 0.4 per market) and far bumpier. Two instruments is closer to the single-market case than to the diversified one. And the 2012 Sharpe is before costs.

In this project

Week 1's first run, from the research log.Rule: 12-month time-series momentum (long if the price is above where it was a year ago, else short), sized to a 10% annual volatility target, with spread costs and carry, on the clean daily table since 2018. Bitcoin: Sharpe 0.59, maximum drawdown −22% against about −77% for buying and holding; that drawdown gap is the main thing trend following buys you. Gold: Sharpe 0.24 after fixing the weekend bug (the first version closed every Friday and reopened every Monday, paying the spread twice a week for nothing). Both numbers are full-history, not yet out-of-sample, so they are a plumbing check, not a result. Next on the log: the 63/126/252-day blend, and checking the 30 January 2026 gold print against a second source.

7 · Failure modes

The first is built into the strategy and cannot be removed, only managed. The other two are mistakes.

The turn.By construction the rule is fully long at the top and fully short at the bottom, because it only knows the past. In a sharp reversal (2009, March 2020) it holds yesterday's winner on the day it becomes the loser. The crash in Lab A shows it.Manage it: size by volatility so the position is already smaller when markets get wild, and blend lookbacks so some of the book turns early.
Crowning a lookback.Picking L because it scored best on your history. Lab B shows the best L is mostly the noise of that one history.Fix: test a range, report the range, and use an average of several.
Judging on the full-history Sharpe.One number over the whole sample hides a rule that made all its money in two years and lost in the other eight.Fix: the yearly table and the out-of-sample period are what count, as the repo rules say.

8 · Implementation

# px: daily closes (one instrument), oldest first; r: daily returns
# sigma: the EWMA vol from the EWMA note (02), already annualised
L      = 252                                    # about 12 months of trading days
signal = np.sign(px / px.shift(L) - 1)          # +1 rose, -1 fell
pos    = (signal * 0.10 / sigma).shift(1)       # 10% vol target; decided at t-1, held over t
pnl    = pos * r - tc * pos.diff().abs()        # position x next-bar return, minus cost on changes

# the blend the plan asks for: average the sign over three lookbacks
signal = sum(np.sign(px / px.shift(k) - 1) for k in (63, 126, 252)) / 3

The project's backtester does the shift(1), the volatility scaling, the leverage cap and the costs itself; a signal function only has to return the ±1 (or the blended fraction). Do not add a second shift inside the signal.

9 · Terminology

Each entry: the technical definition first, then the same idea in everyday words in the orange strip.

time-series momentuma rule that trades each market on the sign of its own past return.if it went up lately, bet on up; if down, bet on down. Each market judged on its own.
lookback (L)the number of days back used to measure the past return.how far back you look to decide whether "lately" was up or down.
long / shorta position that profits from a rise / from a fall.long = you own it and want it to go up. Short = you have bet against it and want it to go down.
sign()+1 for a positive number, −1 for a negative one, 0 for zero.keep only the direction, throw away the size.
volatility targetingscaling the position so its expected risk equals a chosen level: size = target ÷ σ.bet smaller when the market is jumpy, bigger when it is calm, so every bet risks about the same money.
whipsawa sequence of position changes in a sideways market, each losing a little.the rule keeps changing its mind and paying a fee each time, while the market goes nowhere.
drawdownthe fall from a running peak of the equity curve to the next trough.how far below your best-ever point you have fallen. The worst one is the number the firm's risk page will ask for.
Sharpe ratioaverage return divided by its standard deviation, annualised.profit per unit of bumpiness. Around 0.7–1.2 after costs is credible for a first model; 3 reads as overfitting.
out-of-samplea period of data not used while designing the rule.the part of history you kept hidden from yourself, so the test is fair.

Sources

Moskowitz et al.T. Moskowitz, Y. H. Ooi, L. H. Pedersen, "Time Series Momentum", Journal of Financial Economics 104 (2012), 228–250. Sections 1–4 and 6; the return formula is their eq. 5.
Hurst et al.B. Hurst, Y. H. Ooi, L. H. Pedersen, "A Century of Evidence on Trend-Following Investing", Journal of Portfolio Management 44:1 (2017). Sample, lookback mix, decade and crisis results.
Bailey & López de PradoD. Bailey, M. López de Prado, "The Deflated Sharpe Ratio: Correcting for Selection Bias, Backtest Overfitting and Non-Normality" (2014). Why the best lookback on one history is not a result (Lab B).
Bailey, Borwein, López de Prado & Zhu"Pseudo-Mathematics and Financial Charlatanism: The Effects of Backtest Overfitting on Out-of-Sample Performance", Notices of the AMS (2014). Same lesson, with the maths.
Project notesThe Quant Notes doc and notes/research_log.md in xau-btc-models: week-1 numbers and the repo rules.

Named on this page but not in the Literature folder, so quoted from the reading list rather than from the text: R. Carver, Systematic Trading (2015), for EWMAC and the forecast scaling in section 5; N. Jegadeesh and S. Titman, "Returns to Buying Winners and Selling Losers", Journal of Finance 48 (1993), for cross-sectional momentum.

All charts on this page are generated from simulated series inside the page; no market data is used. Part of quant-notes. Next: the EWMA note (02), which supplies the σ that sizes every position here.