Calculate the Mean Absolute Error (MAE) between every unordered pair of tickers’ series in the Toolkit instance.

MAE is the average absolute difference between two series.

The formula is as follows:

\[\text{MAE} = (1 / n) \cdot \text{Σ} | \text{aₜ} - \text{bₜ} |,\;\; \text{with aₜ and bₜ the two tickers' column (Return by default) on the n dates where both have data}\]

It is expressed in the units of the series itself (e.g. a return difference) and answers “how far apart are the two series in a typical period”. Every difference counts in proportion to its size, so unlike get_rmse, which squares the differences and is therefore dominated by a few large gaps, MAE is robust to occasional outliers. A lower value means the two tickers track each other more closely.

This method compares two assets directly, for example how closely a fund tracks its index or how two related stocks move together, rather than an asset against a model’s forecast; see get_rmse for the reasoning, and get_out_of_sample_validation for evaluating actual forecasts.

Also known as: MAD (Mean Absolute Deviation).

Mean Absolute Error (MAE) in Python or via the MCP

Install the Finance Toolkit with:

pip install financetoolkit -U

Then call get_mae as shown below.

from financetoolkit import Toolkit

toolkit = Toolkit(
    ["GLD", "IAU", "GLDM"],
    api_key="FINANCIAL_MODELING_PREP_KEY",
    start_date="2025-01-01",
    end_date="2025-12-31",
)

toolkit.econometrics.get_mae()

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

How closely did the daily returns of the gold ETFs GLD, IAU and GLDM track each other in 2025, measured by the mean absolute error?

Which returns:

  MAE
(‘GLD’, ‘IAU’) 0.0002
(‘GLD’, ‘GLDM’) 0.0003
(‘IAU’, ‘GLDM’) 0.0003

Using Your Own Data

get_mae 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_mae()

Parameters

get_mae accepts the following parameters.

ParameterTypeDescriptionExample
periodstrThe data frequency (daily, weekly, monthly, quarterly, or yearly). Defaults to “daily”."weekly"
columnstrThe historical data column to compare. Defaults to “Return”."Return"
include_benchmarkboolWhether to include “Benchmark” among the tickers paired up. Defaults to False.True
roundingint | NoneThe number of decimals to round the results to. Defaults to None.2
Share