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

Volatility measures the amount of dispersion or variability in returns. It is the square root of the Variance. A higher Volatility indicates greater variability, while a lower Volatility suggests that returns are closer to the mean.

By default this is the close-to-close Volatility, i.e. the standard deviation of the daily returns. The method parameter selects one of four range-based estimators instead, each of which uses more of the day’s price action than just the close and is therefore more statistically efficient (i.e. needs fewer observations to reach the same precision), at the cost of additional assumptions about how prices move:

  • "parkinson" - uses the daily trading range (High vs Low) rather than the close-to-close return, assuming prices follow a continuous geometric Brownian motion with no drift and no overnight jumps.
  • "garman_klass" - extends Parkinson by also incorporating the Open and Close, which allows it to account for the opening jump and makes it more efficient still (assuming, as Parkinson does, no drift and no overnight jumps beyond the modeled open).
  • "rogers_satchell" - drift-independent, meaning it remains unbiased even when the underlying asset has a non-zero expected return over the period, at the cost of still assuming no overnight jumps.
  • "yang_zhang" - a weighted combination of the overnight (close-to-open) Variance, the open-to-close Variance and the Rogers-Satchell Variance. It is both drift-independent and accounts for overnight jumps, which makes it the most statistically efficient of the range-based estimators implemented here.

In every case the daily Volatility is scaled to the given period by multiplying the underlying Variance with the number of trading days within that period (e.g. 252 / 52 for weekly).

Also known as: standard deviation of returns. The range-based estimators are also known as Parkinson’s range-based or high-low Volatility, Garman-Klass range-based Volatility, Rogers-Satchell drift-independent Volatility and Yang-Zhang drift-independent overnight-aware Volatility.

For more information about the range-based estimators, see the following papers:

  • Parkinson, M. (1980). “The Extreme Value Method for Estimating the Variance of the Rate of Return.” Journal of Business, 53(1), 61-65.
  • Garman, M.B., & Klass, M.J. (1980). “On the Estimation of Security Price Volatilities from Historical Data.” Journal of Business, 53(1), 67-78.
  • Rogers, L.C.G., & Satchell, S.E. (1991). “Estimating Variance from High, Low and Close Prices.” Annals of Applied Probability, 1(4), 504-512.
  • Yang, D., & Zhang, Q. (2000). “Drift-Independent Volatility Estimation Based on High, Low, Open, and Close Prices.” Journal of Business, 73(3), 477-491.

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

Calculate the Volatility in Python

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

pip install financetoolkit -U

Then call get_volatility as shown below.

from financetoolkit import Toolkit

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

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

Which returns:

Date AMZN TSLA Benchmark
2021 0.2409 0.5476 0.131
2022 0.5008 0.6668 0.2427
2023 0.3302 0.5406 0.1318
2024 0.2809 0.635 0.1258
2025 0.3442 0.6349 0.1948
2026 0.3161 0.4312 0.1414

And, using the daily trading range instead of only the closes:

toolkit.risk.get_volatility(period="yearly", method="parkinson")
Date AMZN TSLA Benchmark
2021 0.2099 0.426 0.103
2022 0.3717 0.5547 0.1916
2023 0.2611 0.4365 0.1101
2024 0.219 0.4357 0.0989
2025 0.267 0.5062 0.152
2026 0.2681 0.3781 0.1111

Parameters

get_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, Volatility is calculated over a rolling window of this many periods (e.g. period=’monthly’ and rolling=6 gives the rolling 6-month Volatility) instead of one value per period. Only available for method=”close_to_close”. Defaults to None.
  • method (str, optional): Which Volatility estimator to use, one of “close_to_close”, “parkinson”, “garman_klass”, “rogers_satchell” or “yang_zhang”, as described above. Defaults to “close_to_close”.
  • 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 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