Time-Series Momentum
Calculate the Time Series Momentum position of each ticker: long when its excess return of the last year was positive and short when it was negative, scaled to a target volatility, the trend signal of Moskowitz, Ooi and Pedersen (2012).
Where cross-sectional momentum compares assets with each other, time series momentum compares an asset with its own past: in the paper the excess return of the last 12 months of each of 58 futures and forwards (equity indices, currencies, commodities and bonds) predicted its own return of the next month, and a portfolio of the positions did best in extreme up and down markets. Scaling each position by the asset’s volatility gives every asset the same risk.
The formula is as follows:
\[\text{Excess Return} = \prod_{i=1}^{252} (1 + \text{Return}_{i}) - \prod_{i=1}^{252} (1 + \text{Risk Free Return}_{i})\] \[\sigma_{t}^{2} = \text{Observations per Year} \cdot \sum_{i=0}^{\infty} (1 - \delta) \cdot \delta^{i} \cdot (\text{Return}_{t-i} - \text{EWMA Mean}_{t})^{2}\] \[\text{where}\;\; \frac{\delta}{1 - \delta} = 60\] \[\text{Time Series Momentum} = \frac{\operatorname{sign}\left(\text{Excess Return}\right) \cdot 0.4}{\sigma_{t}}\]Where the products run over the last 252 days, \(\sigma_{t}\) is the annualized exponentially weighted volatility of the daily returns with a center of mass of 60 days, the ex ante volatility of the paper, and 0.4 the 40% target volatility the paper scales a single position to. A position of 0.5 is long half the capital and -2 short twice the capital. Each period shows the position at its last trading day, the one held over the next period.
Also known as: time series momentum, TSMOM, trend following, absolute momentum, volatility scaled trend.
Example · QQQ, TLT, GLD · 2024 to 2025
Install the Finance Toolkit with pip install financetoolkit -U, then call get_time_series_momentum:
from financetoolkit import Toolkit
toolkit = Toolkit(
["QQQ", "TLT", "GLD"],
api_key="FINANCIAL_MODELING_PREP_KEY",
start_date="2024-01-01",
end_date="2025-06-30",
)
toolkit.performance.get_time_series_momentum()
Or, with the Finance Toolkit MCP set up, ask an AI assistant such as Claude or ChatGPT:
What time series momentum positions, scaled to a target volatility, did the Invesco QQQ Trust, the iShares 20+ Year Treasury Bond ETF and the SPDR Gold Shares ETF have at the end of each month in the first half of 2025?
Which returns:
| Date | QQQ | TLT | GLD |
|---|---|---|---|
| 2025-01 | 2.1155 | -3.0156 | 2.6763 |
| 2025-02 | 2.1096 | -2.8840 | 2.7030 |
| 2025-03 | 1.8588 | -3.0240 | 2.8193 |
| 2025-04 | 1.1371 | 2.6146 | 2.0483 |
| 2025-05 | 1.2718 | -2.7634 | 1.8418 |
| 2025-06 | 1.4590 | -2.8677 | 1.9456 |
6 rows
Parameters
get_time_series_momentum accepts the following parameters.
| Parameter | Type | Description | Example |
|---|---|---|---|
period | str | The period whose last trading day is shown. Options are: “daily”, “weekly”, “monthly”, “quarterly”, “yearly”. Defaults to “monthly”, as the paper rebalances monthly. | "weekly" |
window | int | The number of daily returns of the lookback. Defaults to 252, 12 months. | 20 |
target_volatility | float | The annualized volatility a position is scaled to. Defaults to 0.4. | 0.4 |
center_of_mass | float | The center of mass of the exponential weights of the volatility, in days. Defaults to 60. | 60 |
rounding | int | None | The number of decimals to round the results to. Defaults to None, which uses the rounding of the Toolkit (4 unless set otherwise). | 2 |
growth | bool | Whether to calculate the growth of the values. Defaults to False. | True |
lag | int | list[int] | The lag to use for the growth calculation. Defaults to 1. | 4 |
standardize | bool | Whether to standardize (Z-Score) the result. When combined with growth=True, standardizes the growth values instead of the raw values. Defaults to False. | True |
transform | str | list[str] | None | Time series steps applied in order, such as “sma:12” (moving average), “ema:12”, “std:12”, “zscore:60”, “percentile:120”, “yoy”, “pct_change:3,annualize:3”, “log”, “diff”, “cumsum” or “hp_trend” and “hp_cycle” (Hodrick-Prescott), before growth. A window needs that many periods of history, so the first periods can be empty. Defaults to None. | None |
show_columns | str | list[str] | None | The columns to keep, a name or a list of names, matched on every column level, or the rows when no column has those names (such as the line items of a financial statement). Names that do not exist are logged, and when none exist the result is returned in full. Defaults to None, which keeps every column. | None, which keeps every column |
References
- Paper Moskowitz, T.J., Ooi, Y.H. and Pedersen, L.H. (2012). “Time Series Momentum.” Journal of Financial Economics, 104(2), 228-250.