Fit a Vector Autoregression (VAR) across every ticker in the Toolkit instance and forecast forecast_steps periods ahead.

Also known as: VAR model, vector autoregressive model.

A VAR jointly models every ticker’s series, regressing each of them on lags lagged values of ALL of them (including itself) – see time_series_model.get_var_forecast for the full formula and estimation method (equation-by-equation OLS, reusing regression_model.get_ols).

VAR Forecast in Python

get_var_forecast is part of the Econometrics module of the open-source Finance Toolkit. Install it with:

pip install financetoolkit -U

Then call get_var_forecast as shown below.

from financetoolkit import Toolkit

toolkit = Toolkit(["AAPL", "MSFT"], api_key="FINANCIAL_MODELING_PREP_KEY")

toolkit.econometrics.get_var_forecast(period="quarterly")

Which returns:

Step AAPL MSFT
1 0.1271 0.1046
2 0.1069 0.0640
3 0.0704 0.0428
4 0.0661 0.0454
5 0.0716 0.0496

Parameters

get_var_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 model. Defaults to “Return”.
  • lags (int, optional): The VAR order. Defaults to 1.
  • forecast_steps (int, optional): The number of periods ahead to forecast. Defaults to 5.
  • include_benchmark (bool, optional): Whether to include “Benchmark” among the tickers modeled jointly. Defaults to False.
  • rounding (int | None, optional): The number of decimals to round the results to. Defaults to None.
Share