Calculates the conditional variance (sigma_t^2) of the returns with a GARCH(1, 1) model fitted to them. Take the square root for the conditional volatility, and see get_garch_forecast for the variance forecast beyond the last observation.

GARCH (Generalized autoregressive conditional heteroskedasticity) is stochastic model for time series, which is for instance used to model volatility clusters, stock return and inflation. It is a generalisation of the ARCH models.

The formula is as follows:

\[\sigma_{t} ^{2} = \text{Omega} + \text{Alpha} \cdot r_{t-1} ^{2} + \text{Beta} \cdot \sigma_{t-1} ^{2}\] \[\sigma_{1} ^{2} = \text{Omega} + (\text{Alpha} + \text{Beta}) \cdot \text{Backcast}\]

Where r_t are the returns (not demeaned) and the Backcast is an exponentially weighted average (decay 0.94) of the first 75 squared returns. Omega, Alpha and Beta maximize the Gaussian log-likelihood, i.e. minimize Σ (ln sigma_t^2 + r_t^2 / sigma_t^2), under Omega, Alpha, Beta > 0 and Alpha + Beta < 1 (see get_garch_parameters).

Also known as: GARCH, volatility clustering, conditional heteroscedasticity.

GARCH Volatility Model in Python or via the MCP

Install the Finance Toolkit with:

pip install financetoolkit -U

Then call get_garch as shown below.

from financetoolkit import Toolkit

toolkit = Toolkit(
    ["BTCUSD"],
    api_key="FINANCIAL_MODELING_PREP_KEY",
    start_date="2021-01-01",
    end_date="2025-12-31",
)

toolkit.risk.get_garch().tail(5)

Or, after setting up the Finance Toolkit MCP, ask:

What was the GARCH(1,1) conditional variance of Bitcoin and the S&P 500 over the last five days of 2025, fitted on their returns from 2021 to 2025?

Which returns:

Date BTCUSD Benchmark
2025-12-27 0.0004 0
2025-12-28 0.0004 0
2025-12-29 0.0004 0
2025-12-30 0.0004 0
2025-12-31 0.0004 0

Parameters

get_garch accepts the following parameters.

ParameterTypeDescriptionExample
periodstrThe data frequency for returns (daily, weekly, monthly, quarterly, or yearly). Defaults to “daily”."weekly"
time_stepsintTime steps to calculate GARCH for. Defaults to None, which uses the length of the returns.252
optimization_tintTime steps to optimize GARCH for. It is only used if no weights are given. Defaults to None, which uses the length of the returns.252
within_periodboolWhether to calculate GARCH within the specified period or for the entire period. Thus whether to look at the GARCH within a specific year (if period = ‘yearly’) or look at the entirety of all years. Defaults to False.True
roundingint | NoneThe number of decimals to round the results to. Defaults to None, which uses the rounding of the Toolkit (4 unless set otherwise).2
growthboolWhether to calculate the growth of the GARCH values over time. Defaults to False.True
lagint | list[int]The lag to use for the growth calculation. Defaults to 1.4
standardizeboolWhether to standardize (Z-Score) the result. When combined with growth=True, standardizes the growth values instead of the raw values. Defaults to False.True
Share