Calculate the Beta, a measurement that assess the systematic risk of a stock or investment.

Beta is a financial metric used to assess the systematic risk of a stock or investment in relation to the overall market. It provides valuable insights into how a particular asset’s returns tend to move in response to fluctuations in the broader market. A stock’s Beta is calculated by analyzing its historical price movements and their correlation with the movements of a market index, typically the benchmark index like the S&P 500.

The formula is as follows:

\[\text{Beta} = \text{Covariance of Asset Returns and Benchmark Returns} / \text{Variance of Benchmark Returns}\]

For a given period, for example monthly, this translates into the following:

\[\text{Beta} = \text{Monthly Covariance of Asset Returns and Benchmark Returns} / \text{Monthly Variance of Benchmark Returns}\]

Beta is read against 1, the benchmark’s own beta: above 1 the asset tends to amplify market moves, below 1 to dampen them. Each period’s Beta comes from the daily returns within that period, so a yearly figure rests on about 250 observations and can swing with a single turbulent month; a rolling window (for example period=’monthly’ with rolling=36) gives a steadier estimate for cost of capital work. A Beta close to zero can come from a low correlation with the market rather than from low volatility, so it is worth checking both before calling a stock defensive.

See definition: https://en.wikipedia.org/wiki/Beta_(finance)

Also known as: market sensitivity, systematic risk.

Beta in Python or via the MCP

Install the Finance Toolkit with:

pip install financetoolkit -U

Then call get_beta as shown below.

from financetoolkit import Toolkit

toolkit = Toolkit(
    ["NVDA", "TSLA", "JPM"],
    api_key="FINANCIAL_MODELING_PREP_KEY",
    start_date="2021-01-01",
    end_date="2025-12-31",
)

toolkit.performance.get_beta()

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

How did the beta of Nvidia, Tesla and JPMorgan Chase against the S&P 500 change each year from 2021 to 2025?

Which returns:

Date NVDA TSLA JPM
2021 2.0431 1.9542 0.8376
2022 2.2001 1.7404 0.8815
2023 2.0217 2.247 0.8723
2024 2.6583 2.38 0.8006
2025 1.8727 2.2342 0.9481

The downside Beta shows how the same stocks moved on the days the S&P 500 fell:

toolkit.performance.get_beta(method="downside")
Date NVDA TSLA JPM
2021 2.0938 1.6149 0.7877
2022 1.9875 1.5848 0.7921
2023 2.1135 2.5952 1.048
2024 2.0508 2.6545 0.9306
2025 1.8311 1.9833 0.9638

Parameters

get_beta 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"
rollingintThe rolling window size to use for the calculation. If you select period = ‘monthly’ and set rolling to 12 you obtain the rolling 12-month Beta. Defaults to None.4
methodstrThe estimator of the Beta. Defaults to “ols”. Choose from: - “ols”: the covariance over the benchmark variance (the formula above). - “blume”: the adjusted Beta of Bloomberg, 0.67 x OLS Beta + 0.33 (Blume, 1971, 1975). - “vasicek”: the OLS Beta shrunk towards the mean Beta of the tickers by the precision of each estimate (Vasicek, 1973). - “dimson”: the sum of the slopes on the lagged, same and leading benchmark returns (Dimson, 1979). - “scholes_williams”: the lagged, same and leading slopes over the benchmark’s autocorrelation (Scholes and Williams, 1977). - “upside” or “downside”: the OLS Beta on the days the benchmark rose or fell.
lagsintThe number of leads and lags of the Dimson Beta. Defaults to 1.2
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