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.

Treynor-Mazuy Model in Python or via the MCP

Install the Finance Toolkit with:

pip install financetoolkit -U

Then call get_treynor_mazuy_model as shown below.

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_treynor_mazuy_model().xs("ARKK", level=0, axis=1)

Or, after setting up the Finance Toolkit MCP, ask:

What were the alpha, beta, market timing coefficient (gamma) and R-squared of ARKK in the Treynor-Mazuy model in each year from 2021 to 2025?

Which returns:

  Alpha Beta Gamma R Squared
2021 -0.0034 1.6646 12.4821 0.2937
2022 -0.0035 2.1567 6.9512 0.5959
2023 0.0015 2.2614 -14.8854 0.529
2024 -0.001 2.1368 -3.1566 0.5658
2025 0.0006 1.8994 -1.3437 0.6767

Parameters

get_treynor_mazuy_model accepts the following parameters.

ParameterTypeDescriptionExample
periodstrThe period to use for the calculation. Defaults to “quarterly” if the Toolkit is initialised with quarterly=True, otherwise “yearly”."quarterly"
roundingint | NoneThe number of decimals to round the results to. Defaults to None, which uses the rounding of the Toolkit (4 unless set otherwise).2
growthboolWhether to calculate the growth of the ratios. Defaults to False.True
lagint | list[int]The lag to use for the growth calculation. Defaults to 1.4
standardizeboolWhether to standardize (Z-Score) the result. When combined with growth=True, standardizes the growth values instead of the raw values. Defaults to False.True
Share