Compounded Volatility
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.
The compounded Volatility keeps the close-to-close returns but scales them differently: rather than the square root of time, it gives the standard deviation of the period’s return when the daily returns compound, the exact value for independent daily returns with the measured mean and variance. It exceeds the close-to-close Volatility when the returns are large (a cryptocurrency’s yearly Volatility) and barely differs for small ones.
The formula is as follows:
\[\text{Compounded Volatility} = \sqrt{(\operatorname{Var}(r) + (1 + g)^{2})^{P} - (1 + g)^{2P}},\;\; \text{with } r \text{ the daily returns},\;\; g \;\text{their geometric mean} \;\left(\operatorname{PRODUCT}(1 + r)^{\frac{1}{n}} - 1 \;\text{over the}\; n \;\text{days}\right) \;\text{and}\; P \;\text{the trading days per period}\]In the Finance Toolkit this is get_volatility with method="compounded", the same function as Volatility.
Example · EURUSD, BTCUSD, ^GSPC, GCUSD · 2021 to 2025
Install the Finance Toolkit with pip install financetoolkit -U, then call get_volatility:
from financetoolkit import Toolkit
toolkit = Toolkit(
["EURUSD", "BTCUSD", "^GSPC", "GCUSD"],
api_key="FINANCIAL_MODELING_PREP_KEY",
start_date="2021-01-01",
end_date="2025-12-31",
)
toolkit.risk.get_volatility(method="compounded", period="yearly")
Which returns:
| Date | EURUSD | BTCUSD | ^GSPC | GCUSD | Benchmark |
|---|---|---|---|---|---|
| 2021 | 0.0526 | 1.5198 | 0.1685 | 0.1377 | 0.1695 |
| 2022 | 0.094 | 0.2548 | 0.1976 | 0.1571 | 0.2013 |
| 2023 | 0.0768 | 1.1812 | 0.1635 | 0.156 | 0.1658 |
| 2024 | 0.0553 | 1.2632 | 0.1565 | 0.1954 | 0.1574 |
| 2025 | 0.0824 | 0.4111 | 0.2203 | 0.3236 | 0.2317 |
Parameters
get_volatility accepts the following parameters.
| Parameter | Type | Description | Example |
|---|---|---|---|
period | str | The data frequency for returns. Options are: “weekly”, “monthly”, “quarterly”, “yearly”. Defaults to “quarterly” if the Toolkit is initialised with quarterly=True, otherwise “yearly”. | "quarterly" |
rolling | int | 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”. At least 2. Defaults to None. | 4 |
method | str | The Volatility estimator, as described above. Options are: “close_to_close” (close-to-close), “parkinson” (Parkinson), “garman_klass” (Garman-Klass), “rogers_satchell” (Rogers-Satchell), “yang_zhang” (Yang-Zhang), “garman_klass_yang_zhang” (Garman-Klass Yang-Zhang), “compounded” (compounded). Defaults to “close_to_close”. | "yang_zhang" |
rounding | int | None | The number of decimals to round the results to. Defaults to None, which uses the rounding of the Toolkit (4 unless set otherwise). | 2 |
growth | bool | Whether to calculate the growth of the Volatility values over time. Defaults to False. | True |
lag | int | list[int] | The lag to use for the growth calculation. Defaults to 1. | 4 |
standardize | bool | Whether to standardize (Z-Score) the result. When combined with growth=True, standardizes the growth values instead of the raw values. Defaults to False. | True |
show_columns | str | list[str] | None | The columns to keep, a name or a list of names, matched on every column level, or the rows when no column has those names (such as the line items of a financial statement). Names that do not exist are logged, and when none exist the result is returned in full. Defaults to None, which keeps every column. | None, which keeps every column |
References
- Library Shares similar logic as backtesting.py’s compute_stats (compounded, Volatility (Ann.) [%])