Calculates factor correlations between each factor. This is useful to understand how correlated each factor is to each other. This is based off the Fama and French 5 Factor model which includes:

  • Market Risk Premium (Mkt-RF): Represents the additional return that investors expect to earn for taking on the risk of investing in the overall market as opposed to a risk-free asset.
  • Size Premium (SMB): Reflects the historical excess return of small-cap stocks over large-cap stocks.
  • Value Premium (HML): Captures the historical excess return of value stocks over growth stocks.
  • Profitability (RMW): Measures the historical excess return of high profitability stocks over low profitability stocks.
  • Investment (CMA): Quantifies the historical excess return of low investment stocks over high investment stocks.

Optionally, it is also possible to see the correlation between the risk-free rate and each factor.

Also known as: factor model correlations.

Factor Correlations in Python

get_factor_correlations is part of the Performance module of the open-source Finance Toolkit. Install it with:

pip install financetoolkit -U

Then call get_factor_correlations as shown below.

from financetoolkit import Toolkit

toolkit = Toolkit(["AAPL", "TSLA"], api_key="FINANCIAL_MODELING_PREP_KEY", start_date="2023-01-01")

toolkit.performance.get_factor_correlations()

Which returns:

  Mkt-RF SMB HML RMW CMA
(2026, ‘Mkt-RF’) 1 0.1702 -0.4054 -0.5902 -0.4198
(2026, ‘SMB’) 0.1702 1 0.2113 -0.1127 0.2437
(2026, ‘HML’) -0.4054 0.2113 1 0.3432 0.7051
(2026, ‘RMW’) -0.5902 -0.1127 0.3432 1 0.4182
(2026, ‘CMA’) -0.4198 0.2437 0.7051 0.4182 1

Parameters

get_factor_correlations accepts the following parameters:

  • period (str, optional): The period to use for the calculation. Defaults to “quarterly” if the Toolkit is initialized with quarterly=True, otherwise “yearly”.
  • factors_to_calculate (list of str, optional): List of factors to calculate scores and residuals for. Defaults to [“Mkt-RF”, “SMB”, “HML”, “RMW”, “CMA”].
  • exclude_risk_free (bool, optional): Whether to exclude the risk-free rate from the results. Defaults to True.
  • rounding (int, optional): The number of decimals to round the results to. Defaults to 4.
Share