FinanceToolkit v1.4.0
This releases includes the Fama and French 5-factor model. Something I've been wanting to add into the Finance Toolkit for some time now. This allows you to understand the explanatory power of the following factors on each ticker included in the Toolkit on any period, let it be yearly, quarterly, monthly or weekly:
- 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.
I've added correlation functions that help you understand how factors correlate with each other over time. For example, the following GIF is created with data from the function performance.get_factor_correlations
.
Next to that, you can perform Linear Regressions on each factor and each factor combination to discover sensitivities of individual assets to each factor (this is not only limited to companies but can also be currencies, commodities, ETFs and more):
from financetoolkit import Toolkit
# Initialize the Finance Toolkit
companies = Toolkit(
tickers=["MSFT", 'AAPL', 'TSLA', 'GOOG', "AMZN", 'MU'], api_key=FMP_KEY, quarterly=False
)
companies.performance.get_fama_and_french_model()
Which returns regression coefficients for all factors for each individual stock:

You have the option to show both the results from a simple linear regression (which is defined as Excess Return = Intercept + Slope * Factor Value + Residuals
) or a multi linear regression (which is defined as Excess Return = Intercept + Beta1 * Mkt-RF + Beta2 * SMB + Beta3 * HML + Beta4 * RMW + Beta5 * CMA + Residuals
) the latter is the default. E.g. you can show the explanatory power of each individual factor for example for Microsoft as follows:
from financetoolkit import Toolkit
# Initialize the Finance Toolkit
companies = Toolkit(
tickers=["MSFT"], api_key=FREE_FMP_KEY, quarterly=False
)
result = companies.performance.get_fama_and_french_model(period='quarterly', method='simple')
result['MSFT'].xs('R Squared', level=1, axis=1).plot(figsize=(15, 5), title=f'Factor Sensitivities of Microsoft')
Which returns the following: