awt_quant.forecast package

Subpackages

Submodules

awt_quant.forecast.garch_forecast module

GARCH Model Optimization and Volatility Forecasting.

This module finds the best GARCH-like model for a given time series, fits it, and visualizes its conditional volatility.

Classes:
  • GARCHOptimizer: Handles GARCH model selection, fitting, and volatility forecasting.

Usage:

garch = GARCHOptimizer(series, dates_train, ticker) best_model = garch.fit() fig = garch.plot_volatility() fig.show()

class awt_quant.forecast.garch_forecast.GARCHOptimizer(series, dates_train, ticker, plot_vol=True)[source]

Bases: object

A class to find and optimize a GARCH-like model for a given time series.

series[source]

Time series data of asset returns.

Type:

pd.Series

dates_train[source]

Corresponding date index for the series.

Type:

pd.Series

ticker[source]

Stock ticker symbol.

Type:

str

plot_vol[source]

Whether to plot the volatility.

Type:

bool

best_model[source]

The best identified GARCH model.

Type:

str

best_p[source]

Optimal p lag order.

Type:

int

best_q[source]

Optimal q lag order.

Type:

int

fitted_model[source]

The fitted GARCH model.

Type:

arch.univariate.base.ARCHModelResult

__init__(series, dates_train, ticker, plot_vol=True)[source]
fit()[source]

Finds the best GARCH model using Bayesian Information Criterion (BIC).

Returns:

The fitted optimal GARCH model.

Return type:

arch.univariate.base.ARCHModelResult

plot_volatility()[source]

Plots the conditional volatility of the fitted GARCH model.

Returns:

A Plotly figure displaying the volatility plot.

Return type:

plotly.graph_objects.Figure

forecast(horizon=10)[source]

Generates a volatility forecast for the next horizon periods.

Parameters:

horizon (int) – Number of future periods to forecast.

Returns:

A DataFrame with the forecasted conditional variances.

Return type:

pd.DataFrame

awt_quant.forecast.lag_llama_forecast module

awt_quant.forecast.macro_forecast module

Macro Data Forecasting and Visualization

This module provides functionality for forecasting macroeconomic time series data using AutoTS and TimeGPT. It includes preprocessing utilities, automated forecasting methods, and visualization tools.

Functions:
  • MacroDataForecasting: A class for managing time series data and forecasting.

  • convert_numpy_floats(obj): Converts NumPy float64 values to native Python floats.

  • api_forecast(series_id): Fetches macroeconomic data and forecasts future values using TimeGPT.

Usage:

time_series_data, meta_data = get_macro(“GDP”) forecasting = MacroDataForecasting(time_series_data) forecast_results = forecasting.execute_forecasts()

class awt_quant.forecast.macro_forecast.MacroDataForecasting(time_series, meta_data=None)[source]

Bases: object

A class for forecasting macroeconomic time series data using AutoTS.

__init__(time_series, meta_data=None)[source]

Initializes the MacroDataForecasting class.

Parameters:
  • time_series (pd.DataFrame) – The macroeconomic time series data.

  • meta_data (dict, optional) – Metadata related to the time series.

preprocess_data(method='average', normalize=False, return_type=None, na_method='drop')[source]

Preprocesses the time series data by handling missing values and formatting dates.

Parameters:
  • method (str, optional) – Method to handle missing values (‘average’, ‘interpolate’). Defaults to ‘average’.

  • normalize (bool, optional) – Whether to normalize the data. Defaults to False.

  • return_type (str, optional) – Type of return calculation (‘log’, ‘percent’) or None. Defaults to None.

  • na_method (str, optional) – Method to handle missing values (‘drop’, ‘ffill’, ‘interpolate’). Defaults to ‘drop’.

forecast_with_autots(forecast_length=30, frequency='infer', prediction_interval=0.9, model_list='superfast', transformer_list='superfast', ensemble='distance', max_generations=4, num_validations=1, validation_method='backward', metric_weighting={'mae_weighting': 0.5, 'smape_weighting': 0.5}, drop_most_recent=0, n_jobs='auto')[source]

Generates forecasts using the AutoTS library with enhanced parameterization.

Parameters:
  • forecast_length (int, optional) – Number of periods to forecast. Defaults to 30.

  • frequency (str, optional) – Frequency of the time series data. Defaults to ‘infer’.

  • prediction_interval (float, optional) – Prediction interval for the forecast. Defaults to 0.9.

  • model_list (list or str, optional) – Models to be used in the search. Defaults to ‘superfast’.

  • transformer_list (list or str, optional) – Data transformations to be applied. Defaults to ‘superfast’.

  • ensemble (str, optional) – Ensemble method to use. Defaults to ‘distance’.

  • max_generations (int, optional) – Number of generations for the model search. Defaults to 4.

  • num_validations (int, optional) – Number of validation sets used in model selection. Defaults to 1.

  • validation_method (str, optional) – Method for time series cross-validation. Defaults to ‘backward’.

  • metric_weighting (dict, optional) – Weighting of different performance metrics. Defaults to {‘smape_weighting’: 0.5, ‘mae_weighting’: 0.5}.

  • drop_most_recent (int, optional) – Number of most recent data points to drop. Defaults to 0.

  • n_jobs (int or str, optional) – Number of jobs to run in parallel. Defaults to ‘auto’.

Returns:

Dictionary containing forecast results, lower and upper bounds.

Return type:

dict

execute_forecasts(na_method='drop')[source]

Executes the full forecasting pipeline including preprocessing and forecasting.

Parameters:

na_method (str, optional) – Method to handle missing values. Defaults to ‘drop’.

Returns:

Forecast results.

Return type:

dict

awt_quant.forecast.macro_forecast.convert_numpy_floats(obj)[source]

Recursively converts NumPy float64 values to Python native float.

Parameters:

obj (any) – Object containing NumPy floats.

Returns:

Object with converted float values.

Return type:

any

async awt_quant.forecast.macro_forecast.api_forecast(series_id)[source]

Fetches macroeconomic data and forecasts future values using TimeGPT.

Parameters:

series_id (str) – The macroeconomic series ID.

Returns:

Dictionary containing forecasted values.

Return type:

dict

Module contents