Calculate the Henriksson-Merton market timing model for each asset in the Toolkit instance.

Like the Treynor-Mazuy model (see get_treynor_mazuy_model), this separates market-timing skill from selectivity, but 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: Henriksson-Merton piecewise timing model, HM model.

No programming experience? With the Finance Toolkit MCP server, AI assistants such as Claude and ChatGPT can calculate the Henriksson-Merton Model for you. Just ask in plain English.

Calculate the Henriksson-Merton Model in Python

The Henriksson-Merton Model is available in the Performance module of the open-source Finance Toolkit. Install it with:

pip install financetoolkit -U

Then call get_henriksson_merton_model as shown below.

from financetoolkit import Toolkit

toolkit = Toolkit(["AAPL", "TSLA"], api_key="FINANCIAL_MODELING_PREP_KEY")

toolkit.performance.get_henriksson_merton_model().xs("AAPL", level=0, axis=1)

Which returns:

Date Alpha Beta Up Market Beta R Squared
2024 0.0013 1.1387 -0.3553 0.2926
2025 -0.0009 1.1732 0.152 0.5673
2026 0.0008 0.7243 -0.1232 0.1088

Parameters

get_henriksson_merton_model accepts the following parameters:

  • period (str, optional): The period to use for the calculation. Defaults to “quarterly” if the Toolkit is initialised with quarterly=True, otherwise “yearly”.
  • rounding (int, optional): The number of decimals to round the results to. Defaults to 4.
  • growth (bool, optional): Whether to calculate the growth of the ratios. Defaults to False.
  • lag (int | str, optional): The lag to use for the growth calculation. Defaults to 1.
  • standardize (bool, optional): Whether to standardize (Z-Score) the result. When combined with growth=True, standardizes the growth values instead of the raw values. Defaults to False.

The Performance module page introduces the module, and the sidebar lists all of its functions.

Share