Calculate the exponentially weighted moving average (EWMA) Volatility of an investment portfolio or asset’s daily returns, following the RiskMetrics methodology.

Unlike a fixed-window rolling Volatility, EWMA Volatility weights recent observations more heavily than older ones, so it reacts faster to changes in the underlying volatility regime. It is a simpler, more interpretable alternative to a full GARCH fit.

The formula is as follows:

\[\text{EWMA Variance} (t) = \lambda \cdot \text{EWMA Variance} (t-1) + (1 - \lambda) \cdot \operatorname{Return}(t-1) ^{2}\]

Also known as: RiskMetrics volatility, exponentially weighted volatility.

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

Calculate the EWMA Volatility in Python

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

pip install financetoolkit -U

Then call get_ewma_volatility as shown below.

from financetoolkit import Toolkit

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

toolkit.risk.get_ewma_volatility()

Which returns:

Date AMZN TSLA Benchmark
2026-06-22 0.0229 0.0279 0.0099
2026-06-23 0.0223 0.0304 0.0103
2026-06-24 0.0216 0.0296 0.01
2026-06-25 0.022 0.0287 0.0097
2026-06-26 0.0225 0.0281 0.0096
2026-06-29 0.0234 0.0345 0.0101
2026-06-30 0.0228 0.0338 0.01
2026-07-01 0.0224 0.0328 0.0097
2026-07-02 0.0218 0.037 0.0094
2026-07-06 0.0211 0.0395 0.0093

Parameters

get_ewma_volatility accepts the following parameters:

  • lambda_ (float, optional): The decay factor. Higher values weight the past more heavily (slower to react), lower values weight recent returns more heavily (faster to react). RiskMetrics uses 0.94 for daily data. Defaults to 0.94.
  • 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 EWMA 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