arbitragelab.time_series_approach.arima_predict

The module implements the ARIMA forecast of any time series using the Auto-ARIMA approach.

Module Contents

Classes

AutoARIMAForecast

Auto ARIMA forecast generator function.

Functions

get_trend_order(→ int)

Get trend order for a time series using 95% ADF test.

get_trend_order(y_train: pandas.Series, max_order: int = 10) int

Get trend order for a time series using 95% ADF test.

Parameters:
  • y_train – (pd.Series) Series to test.

  • max_order – (int) Highest order value that is being tested.

Returns:

(int) Trend order, 0 means that y_train is already stationary.

class AutoARIMAForecast(start_p: int = 0, start_q: int = 0, max_p: int = 5, max_q: int = 5)

Auto ARIMA forecast generator function.

get_best_arima_model(y_train: pandas.Series, verbose: bool = False, silence_warnings: bool = True)

Using the AIC approach from pmdarima library, choose the best fit ARIMA(d, p, q) parameters.

Parameters:
  • y_train – (pd.Series) Training series.

  • verbose – (bool) Flag to print model fit logs.

  • silence_warnings – (bool) Flag to silence warnings from the Auto ARIMA model - convergence warnings etc.

predict(y: pandas.Series, retrain_freq: int = 1, train_window: int = None, silence_warnings: bool = True) pandas.Series

Predict out-of-sample series using already fit ARIMA model. The algorithm retrains the model with retrain_freq either by appending new observations to train data (train_window = None) or by using the latest train_window observations + latest out-of-sample observations y.

Parameters:
  • y – (pd.Series) Out-of-sample series (used to generate rolling forecast).

  • retrain_freq – (int) Model retraining frequency. Model is fit on every train_freq step.

  • train_window – (int) Number of data points from train dataset used in model retrain. If None, use all train set.

  • silence_warnings – (bool) Flag to silence warnings from the Auto ARIMA model - convergence warnings etc.

Returns:

(pd.Series) Series of forecasted values.