Garman-Klass Volatility
Garman-Klass Volatility 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).
The formula is as follows:
\[\text{Garman-Klass Variance} = \operatorname{Mean}(0.5 \cdot \ln(H / L) ^{2} - (2 \cdot \text{ln}\; 2 - 1) \cdot \ln(C / O) ^{2})\]Source: Garman, M.B., & Klass, M.J. (1980). “On the Estimation of Security Price Volatilities from Historical Data.” Journal of Business, 53(1), 67-78.
In the Finance Toolkit this is get_volatility with method="garman_klass"; the Volatility page has the function’s full description.
Garman-Klass Volatility in Python
Install the Finance Toolkit with:
pip install financetoolkit -U
Then call get_volatility as shown below.
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="garman_klass", period="yearly")
Which returns:
| Date | EURUSD | BTCUSD | ^GSPC | GCUSD | Benchmark |
|---|---|---|---|---|---|
| 2021 | 0.0535 | 0.809 | 0.1048 | 0.1496 | 0.1094 |
| 2022 | 0.1021 | 0.5488 | 0.1813 | 0.1599 | 0.188 |
| 2023 | 0.0736 | 0.3849 | 0.1058 | 0.1365 | 0.1089 |
| 2024 | 0.0603 | 0.4724 | 0.0975 | 0.1492 | 0.0997 |
| 2025 | 0.0744 | 0.3889 | 0.1436 | 0.1913 | 0.1441 |
Parameters
get_volatility accepts the following parameters.
| Parameter | Type | Description | Example |
|---|---|---|---|
period | str | The data frequency for returns (weekly, monthly, quarterly, or 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”. Defaults to None. | 4 |
method | str | 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”. | "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 |