Calculate the Excess Volatility of an investment portfolio or asset’s returns for a given period based on the daily historical returns.

Excess Volatility is the Volatility of the Excess Return, i.e. the daily return minus the risk free rate, scaled to the given period in the same way as the Volatility.

Also known as: standard deviation of excess returns.

No programming experience? With the Finance Toolkit MCP server, AI assistants such as Claude and ChatGPT can calculate the Excess Volatility for you. Just ask in plain English.

Calculate the Excess Volatility in Python

The Excess Volatility is available in the Risk module of the open-source Finance Toolkit. Install it with:

pip install financetoolkit -U

Then call get_excess_volatility as shown below.

from financetoolkit import Toolkit

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

toolkit.risk.get_excess_volatility(period="yearly")

Which returns:

Date AMZN TSLA Benchmark
2021 0.2414 0.5483 0.1333
2022 0.5207 0.686 0.2663
2023 0.3421 0.5535 0.1527
2024 0.2841 0.6346 0.1336
2025 0.3435 0.635 0.1946
2026 0.3196 0.4331 0.1446

Parameters

get_excess_volatility accepts the following parameters:

  • period (str, optional): The data frequency for returns (weekly, monthly, quarterly, or yearly). Defaults to “quarterly” if the Toolkit is initialised with quarterly=True, otherwise “yearly”.
  • rolling (int, optional): The rolling window size to use for the calculation. If set, Excess Volatility is calculated over a rolling window of this many periods (e.g. period=’monthly’ and rolling=6 gives the rolling 6-month Excess Volatility) instead of one value per period. Defaults to None.
  • rounding (int | None, optional): The number of decimals to round the results to. Defaults to 4.
  • growth (bool, optional): Whether to calculate the growth of the Excess Volatility values over time. Defaults to False.
  • lag (int | list[int], 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 Risk module page introduces the module, and the sidebar lists all of its functions.

Share