Calculate the Treynor-Mazuy market timing model for each asset in the Toolkit instance.

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). The Treynor-Mazuy model adds a quadratic term in the benchmark excess return to the regression: 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} + \text{Gamma} \cdot \text{Benchmark Excess Return} ^{2} + \text{Residuals}\]

Gamma > 0 indicates positive market-timing ability; Gamma <= 0 indicates no timing ability.

Also known as: Treynor-Mazuy quadratic timing model, TM model.

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

Calculate the Treynor-Mazuy Model in Python

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

pip install financetoolkit -U

Then call get_treynor_mazuy_model as shown below.

from financetoolkit import Toolkit

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

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

Which returns:

Date Alpha Beta Gamma R Squared
2024 0.0009 0.944 -9.4286 0.294
2025 -0.0005 1.2237 1.6352 0.5693
2026 0.0006 0.6632 -2.6122 0.1087

Parameters

get_treynor_mazuy_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