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.

The formula is as follows:

\[\text{y'ₜ} = \Delta \text{ᵈYₜ},\;\; \text{the}\; \text{column} \;\text{level} (\text{Adj Close by default}) \text{differenced}\; d \;\text{times} (d = 1 \;\text{by default})\] \[\text{y'ₜ} - \mu = \operatorname{Σ}(i = 1..p) \text{φᵢ} \cdot (\text{y'ₜ₋ᵢ} - \mu) + \text{epsilonₜ} + \operatorname{Σ}(j = 1..q) \text{thetaⱼ} \cdot \text{epsilonₜ₋ⱼ},\;\; \text{with}\; p = q = 1 \;\text{by default and}\; \mu \;\text{the mean} (d = 0) \text{or drift} (d \geq 1) \text{of}\; \text{y'ₜ} \;\text{when}\; \text{include\_constant} = \text{True},\;\; \text{and}\; \mu = 0 \;\text{otherwise}\]
  • Fitted by exact Maximum Likelihood via the Kalman filter (statsmodels ARIMA)
\[\text{Forecast:}\;\; \text{the conditional mean}\; E \left[Y_{T} + h | \text{Y\_1..Y\_T}\right] \text{for}\; h = \text{1..forecast\_steps},\;\; \text{in levels}\]

ARIMA Forecast in Python or via the MCP

Install the Finance Toolkit with:

pip install financetoolkit -U

Then call get_arima_forecast as shown below.

from financetoolkit import Toolkit

toolkit = Toolkit(
    ["GCUSD"],
    api_key="FINANCIAL_MODELING_PREP_KEY",
    start_date="2021-01-01",
    end_date="2025-12-31",
)

toolkit.econometrics.get_arima_forecast(forecast_steps=10)

Or, after setting up the Finance Toolkit MCP, ask:

What does an ARIMA(1,1,1) model fitted to the daily gold price from 2021 to 2025 forecast for the next ten days?

Which returns:

Step GCUSD
1 4348.34
2 4348.38
3 4350.82
4 4352.47
5 4354.38
6 4356.2
7 4358.05
8 4359.89
9 4361.73
10 4363.57

Using Your Own Data

get_arima_forecast runs on any data, not only prices: ratios, economic indicators, yield curves or your own dataset. Pass a DataFrame, a Series or a dictionary of them to Econometrics as data, with the dates in the rows or the columns, and set changes to how its changes are calculated: "percentage", "log", "difference" for rates and ratios, or None when the data are changes already. For example, for the monthly unemployment rates of the United States and Germany:

from financetoolkit import Economics, Econometrics

economics = Economics(start_date="2000-01-01")

unemployment = economics.get_unemployment_rate(
    countries=["United States", "Germany"], period="monthly"
)

econometrics = Econometrics(data=unemployment, changes="difference")

econometrics.get_arima_forecast()

Parameters

get_arima_forecast accepts the following parameters.

ParameterTypeDescriptionExample
periodstrThe data frequency (daily, weekly, monthly, quarterly, or yearly). Defaults to “daily”."weekly"
columnstrThe historical data column to fit. Defaults to “Adj Close”."Close"
pintThe autoregressive order. Defaults to 1.2
dintThe number of times to difference the series. Defaults to 1 (the typical choice for a non-stationary price level series).1
qintThe moving-average order. Defaults to 1.2
forecast_stepsintThe number of periods ahead to forecast. Defaults to 5.10
include_constantboolWhether to estimate the mean of the differenced series (its drift for d >= 1). Defaults to True – see time_series_model.get_arima_forecast for when to set this to False.False
include_benchmarkboolWhether to include “Benchmark” among the tickers forecast. Defaults to False.True
roundingint | NoneThe number of decimals to round the results to. Defaults to None.2
Share