CAPM, or the Capital Asset Pricing Model, is a financial model used to estimate the expected return on an investment, such as a stock or portfolio of stocks. It provides a framework for evaluating the risk and return trade-off of an asset or portfolio in relation to the overall market. CAPM is based on the following key components:

  • Risk-Free Rate (Rf): This is the theoretical return an investor could earn from an investment with no risk of financial loss. It is typically based on the yield of a government bond.
  • Market Risk Premium (Rm - Rf): This 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. It is calculated as the difference between the expected return of the market (Rm) and the risk-free rate (Rf).
  • Beta (β): Beta is a measure of an asset’s or portfolio’s sensitivity to market movements. It quantifies how much an asset’s returns are expected to move in relation to changes in the overall market. A beta of 1 indicates that the asset moves in line with the market, while a beta greater than 1 suggests higher volatility, and a beta less than 1 indicates lower volatility.

The Capital Asset Pricing Model (CAPM) is a widely used financial model that helps in determining the expected return of an asset or portfolio based on its systematic risk and the prevailing risk-free rate in the market. CAPM provides insights into how an asset or investment should be priced in order to offer an appropriate rate of return, given its level of risk compared to the overall market.

The formula is as follows:

\[\text{Capital Asset Pricing Model} = \text{Risk Free Rate} + \text{Beta} \cdot (\text{Benchmark Returns} - \text{Risk Free Rate})\]

See definition: https://en.wikipedia.org/wiki/Capital_asset_pricing_model

Also known as: CAPM, expected return model.

No programming experience? With the Finance Toolkit MCP server, AI assistants such as Claude and ChatGPT can calculate the Capital Asset Pricing Model (CAPM) for you. Just ask in plain English.

Calculate the Capital Asset Pricing Model (CAPM) in Python

The Capital Asset Pricing Model (CAPM) is available in the Performance module of the open-source Finance Toolkit. Install it with:

pip install financetoolkit -U

Then call get_capital_asset_pricing_model as shown below.

from financetoolkit import Toolkit

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

toolkit.performance.get_capital_asset_pricing_model()

Which returns:

Date AAPL TSLA
2021 0.3494 0.4914
2022 -0.2646 -0.3666
2023 0.2633 0.4905
2024 0.2266 0.4924
2025 0.1938 0.3135
2026 0.0822 0.1364

Parameters

get_capital_asset_pricing_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”.
  • rolling (int, optional): The rolling window size to use for the Beta component of the calculation. If set, Beta is estimated over a rolling window of this many periods across the full return history instead of per period. Defaults to None.
  • 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