rolling_volatility

qf_lib.common.utils.volatility.rolling_volatility.rolling_volatility(qf_series: qf_lib.containers.series.qf_series.QFSeries, frequency: qf_lib.common.enums.frequency.Frequency = None, annualise: bool = True, window_size: int = None)qf_lib.containers.series.qf_series.QFSeries[source]

Calculates the rolling volatility for the given series of returns. If the annualise parameter is set to be True, then it is obligatory to specify frequency.

Parameters
  • qf_series (QFSeries) – series of returns or prices

  • frequency (Frequency) – the frequency of samples in the returns series; it is only obligatory to specify frequency if the annualise parameter is set to True, which is a default value

  • annualise (bool) – True if the volatility values should be annualised; False otherwise. If it is set to True, then it is obligatory to specify a frequency of the returns series.

  • window_size (int) – number of samples from which the rolling volatility will be calculated. If it is not set, then only overall volatility (of the whole series) will be calculated

Returns

Series of volatility values for each day concerning last window_size days.

Return type

QFSeries