VolatilityForecast¶

class
qf_lib.common.utils.volatility.volatility_forecast.
VolatilityForecast
(returns_tms: qf_lib.containers.series.qf_series.QFSeries, vol_process: arch.univariate.volatility.VolatilityProcess, method: str = 'analytic', horizon: int = 1, annualise: bool = True, frequency: qf_lib.common.enums.frequency.Frequency = <Frequency.DAILY: 252>)[source]¶ Bases:
object
Creates class used for vol forecasting: describes the volatility forecast configuration as well as the input and output data (output is created and assigned by calling one of the class methods).
An instance of this class should describe one specific forecast and store its parameters. Parameters should NOT be modified after calling one of the calculation methods (only one call is allowed)
 Parameters
returns_tms (QFSeries) – series of returns of the asset
vol_process (VolatilityProcess) – volatility process used for forecasting. For example EGARCH(p=p, o=o, q=q)
horizon (str) – horizon for the volatility forecast. It is expressed in the frequency of the returns provided
method (int) – method of forecast calculation. Possible: ‘analytic’, ‘simulation’ or ‘bootstrap’ ‘analytic’ is the fastest but is not available for EGARCH and possibly some other models. For details check arch documentation
annualise (bool) – flag indicating whether the result is annualised; True by default
frequency (Frequency) – if annualise is True, this should be the frequency of the returns timeseries that is provided as input; not used if annualise is False.
Methods
calculate_single_forecast
(multiplier)Calculates volatility forecast for single asset.
calculate_timeseries
(window_len, multiplier)Calculates volatility forecast for single asset.

calculate_single_forecast
(multiplier: int = 1000) → float[source]¶ Calculates volatility forecast for single asset. It is expressed in the frequency of returns. Value is calculated based on the configuration as in the object attributes. The result of the calculation is returned as well as assigned as self.forecasted_volatility object attribute.
 Parameters
multiplier (int) – ex. 100 (should be > 1) improves the optimization performance, as for very small values the results may be faulty; after optimization the results are scaled back (division by multiplier value)
 Returns
Forecasted value of the volatility.
 Return type
float

calculate_timeseries
(window_len: int, multiplier: int = 1) → qf_lib.containers.series.qf_series.QFSeries[source]¶ Calculates volatility forecast for single asset. It is expressed in the frequency of returns. Value is calculated based on the configuration as in the object attributes. The result of the calculation is returned as well as assigned as self.forecasted_volatility object attribute.
 Parameters
window_len (int) – size of the rolling window, number of rows used as input data to calculate forecasted volatility
multiplier (int) – ex. 100 (should be > 1) improves the optimization performance, as for very small values the results may be faulty; after optimization the results are scaled back (division by multiplier value)
 Returns
Timeseries of forecasted volatility.
 Return type