ARIMA Forecast
Fit an ARIMA(p, d, q) model to every ticker’s price series in the Toolkit instance and forecast forecast_steps periods ahead.
Also known as: Box-Jenkins model, autoregressive integrated moving average.
An ARIMA(p, d, q) model differences the series d times to remove a (stochastic) trend, then fits an autoregressive-moving-average model to the result – see time_series_model.get_arima_forecast for the full formula, estimation method (exact Maximum Likelihood via the Kalman filter) and its practical caveats.
ARIMA Forecast in Python
get_arima_forecast is part of the Econometrics module of the open-source Finance Toolkit. Install it with:
pip install financetoolkit -U
Then call get_arima_forecast as shown below.
from financetoolkit import Toolkit
toolkit = Toolkit(["AAPL", "MSFT"], api_key="FINANCIAL_MODELING_PREP_KEY")
toolkit.econometrics.get_arima_forecast(period="quarterly")
Which returns:
| Step | AAPL | MSFT |
|---|---|---|
| 1 | 138.273 | 243.199 |
| 2 | 147.039 | 250.190 |
| 3 | 154.992 | 257.106 |
| 4 | 162.323 | 264.014 |
| 5 | 169.180 | 270.922 |
Parameters
get_arima_forecast accepts the following parameters:
- period (str, optional): The data frequency (daily, weekly, monthly, quarterly, or yearly). Defaults to “daily”.
- column (str, optional): The historical data column to fit. Defaults to “Adj Close”.
- p (int, optional): The autoregressive order. Defaults to 1.
- d (int, optional): The number of times to difference the series. Defaults to 1 (the typical choice for a non-stationary price level series).
- q (int, optional): The moving-average order. Defaults to 1.
- forecast_steps (int, optional): The number of periods ahead to forecast. Defaults to 5.
- include_constant (bool, optional): Whether to estimate a free intercept.
Defaults to True – see
time_series_model.get_arima_forecastfor when to set this to False. - include_benchmark (bool, optional): Whether to include “Benchmark” among the tickers forecast. Defaults to False.
- rounding (int | None, optional): The number of decimals to round the results to. Defaults to None.