Forecast Error
Calculate the forecast error between every pair of tickers: how far apart the two series are in a typical period, as the Root Mean Squared Error or the Mean Absolute Error.
This controller method compares two ASSETS’ series directly, treating one as a naive “forecast” proxy for the other – a simple, tracking-error style measure of how closely two series move together in absolute deviation terms (e.g. a portfolio versus a benchmark, or one asset as a naive stand-in forecast for a similar one). For evaluating an actual FORECASTING MODEL (ARIMA/VAR) rather than one asset as a naive proxy for another, use get_out_of_sample_validation instead.
The formula for the RMSE is as follows:
\[\text{RMSE} = \sqrt{\frac{1}{n} \cdot \sum(a_{t} - b_{t})^{2}},\;\; \text{with } a_{t} \text{ and } b_{t} \text{ the two tickers' column (Return by default) on the } n \text{ dates where both have data}\]The formula for the MAE is as follows:
\[\text{MAE} = \frac{1}{n} \cdot \sum\left|a_{t} - b_{t}\right|,\;\; \text{with } a_{t} \text{ and } b_{t} \text{ the two tickers' column (Return by default) on the } n \text{ dates where both have data}\]Both are expressed in the units of the series itself (e.g. a return difference) and answer “how far apart are the two series in a typical period”; a lower value means the two tickers track each other more closely. The RMSE squares the differences and is therefore dominated by a few large gaps, while in the MAE every difference counts in proportion to its size, so the MAE is robust to occasional outliers.
For a fund against its index the RMSE comes close to the tracking error but is not the same: the tracking error (Performance.get_tracking_error) is the Standard Deviation of the return differences, which leaves out their average, while the RMSE includes it. Both are per period, so a daily RMSE is usually multiplied by the square root of 252 to annualize it.
Also known as: RMSE, RMSD (Root Mean Squared Deviation), MAE, MAD (Mean Absolute Deviation), forecast accuracy.
Example · IVV, VOO · 2025
Install the Finance Toolkit with pip install financetoolkit -U, then call get_forecast_error:
from financetoolkit import Toolkit
toolkit = Toolkit(
["IVV", "VOO"],
api_key="FINANCIAL_MODELING_PREP_KEY",
start_date="2025-01-01",
end_date="2025-12-31",
)
toolkit.econometrics.get_forecast_error(include_benchmark=True)
Or, with the Finance Toolkit MCP set up, ask an AI assistant such as Claude or ChatGPT:
How closely did the daily returns of the iShares Core S&P 500 (IVV) and Vanguard S&P 500 (VOO) ETFs follow each other and the S&P 500 in 2025, measured by the root mean squared error?
Which returns:
| Item | RMSE |
|---|---|
| ('IVV', 'VOO') | 0.0004 |
| ('IVV', 'Benchmark') | 0.0009 |
| ('VOO', 'Benchmark') | 0.0010 |
3 rows
Using Your Own Data
get_forecast_error 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_forecast_error()
Parameters
get_forecast_error accepts the following parameters.
| Parameter | Type | Description | Example |
|---|---|---|---|
period | str | The data frequency (daily, weekly, monthly, quarterly, or yearly). Defaults to “daily”. | "weekly" |
column | str | The historical data column to compare. Defaults to “Return”. | "Return" |
include_benchmark | bool | Whether to include “Benchmark” among the tickers paired up. Defaults to False. | True |
method | str | The error measure. Options are: “rmse” (Root Mean Squared Error), “mae” (Mean Absolute Error). Defaults to “rmse”. | "rmse" |
rounding | int | None | The number of decimals to round the results to. Defaults to None. | 2 |
show_columns | str | list[str] | None | The columns to keep, a name or a list of names, matched on every column level, or the rows when no column has those names (such as the line items of a financial statement). Names that do not exist are logged, and when none exist the result is returned in full. Defaults to None, which keeps every column. | None, which keeps every column |