Market Timing Model
Calculate a market timing model for each asset: whether the manager raised the exposure to the market before it rose and lowered it before it fell, with the Treynor-Mazuy or the Henriksson-Merton model.
Jensen’s Alpha and Beta from a plain CAPM regression cannot distinguish stock-picking skill (selectivity) from market-timing skill (shifting exposure ahead of market moves). Both models add a timing term in the benchmark excess return to the regression.
The Treynor-Mazuy model adds a quadratic term: a manager who successfully increases (decreases) market exposure ahead of up (down) markets will show a return profile that curves upward as a function of the benchmark return, captured by a positive quadratic coefficient (Gamma). The formula is as follows:
\[\text{Excess Return} = \text{Alpha} + \text{Beta} \cdot \text{Benchmark Excess Return} + \Gamma \cdot \text{Benchmark Excess Return}^{2} + \text{Residuals}\]Gamma > 0 indicates positive market-timing ability; Gamma <= 0 indicates no timing ability.
The Henriksson-Merton model models timing as a piecewise (rather than quadratic) change in Beta: a “down-market” Beta and an “up-market” Beta. The formula is as follows:
\[\text{Excess Return} = \text{Alpha} + \text{Beta} \cdot \text{Benchmark Excess Return} + \text{Up Market Beta} \cdot \max(\text{Benchmark Excess Return},\; 0) + \text{Residuals}\]Beta is the “down-market” Beta (the portfolio’s market exposure when the benchmark excess return is negative), and Beta + Up Market Beta is the “up-market” Beta. Up Market Beta > 0 indicates positive market-timing ability; Up Market Beta <= 0 indicates no timing ability.
Also known as: Treynor-Mazuy quadratic timing model, TM model, Henriksson-Merton piecewise timing model, HM model, market timing regression.
Example · ARKK, JEPI · 2021 to 2025
Install the Finance Toolkit with pip install financetoolkit -U, then call get_market_timing_model:
from financetoolkit import Toolkit
toolkit = Toolkit(
["ARKK", "JEPI"],
api_key="FINANCIAL_MODELING_PREP_KEY",
start_date="2021-01-01",
end_date="2025-12-31",
)
toolkit.performance.get_market_timing_model().xs("ARKK", level=0, axis=1)
Or, with the Finance Toolkit MCP set up, ask an AI assistant such as Claude or ChatGPT:
Did ARK Innovation (ARKK) time the market in each year from 2021 to 2025, according to the Treynor-Mazuy model?
Which returns:
| Item | Alpha | Beta | Gamma | R Squared |
|---|---|---|---|---|
| 2021 | -0.0034 | 1.6646 | 12.3590 | 0.2937 |
| 2022 | -0.0035 | 2.1576 | 6.9886 | 0.5962 |
| 2023 | 0.0015 | 2.2602 | -15.0113 | 0.5289 |
| 2024 | -0.0010 | 2.1365 | -3.1024 | 0.5657 |
| 2025 | 0.0006 | 1.8989 | -1.3408 | 0.6766 |
5 rows
Parameters
get_market_timing_model accepts the following parameters.
| Parameter | Type | Description | Example |
|---|---|---|---|
period | str | The period to use for the calculation. Options are: “daily”, “weekly”, “monthly”, “quarterly”, “yearly”. Defaults to “quarterly” if the Toolkit is initialised with quarterly=True, otherwise “yearly”. | "quarterly" |
method | str | The timing model. Options are: “treynor_mazuy” (the quadratic timing term, Gamma), “henriksson_merton” (the piecewise timing term, Up Market Beta). Defaults to “treynor_mazuy”. | "treynor_mazuy" |
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 ratios. 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 |
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 Treynor, J., & Mazuy, K. (1966). “Can Mutual Funds Outguess the Market?” Harvard Business Review, 44(4), 131-136.
- Paper Henriksson, R.D., & Merton, R.C. (1981). “On Market Timing and Investment Performance II: Statistical Procedures for Evaluating Forecasting Skills.” Journal of Business, 54(4), 513-533.
- Library Shares similar logic as PerformanceAnalytics (R)’s MarketTiming (TM)
- Library Shares similar logic as PerformanceAnalytics (R)’s MarketTiming (HM)