KPI functions
If you have created KPI mappings in the Exabel app, you can retrieve the proxy time series and the predictions from these mappings using DSL signals referring to the KPI mapping group. You can also retrieve predictions from the auto-models and custom models.
- kpi_proxy(kpi_group: int, *, forecast: bool = True, resample: bool = True)
Retrieve the proxy time series from a KPI mapping group.
The company can be used as the evaluation entity if there is only one mapping for that company within the given KPI mapping group. If there are several FactSet segments or Visible Alpha line items that have been mapped for the company, then the KPI must be specified by using the segment or the line item as the evaluation entity.
Every night, the Exabel system calculates the forecasted and resampled version of the proxy time series as part of updating the KPI mapping results. This time series is then persisted. When this DSL signal is used with
forecast=True
andresample=True
(the default), it is this persisted version of the proxy which is retrieved, whereas if eitherforecast
orresample
is set toFalse
, the underlying proxy signal is evaluated on the fly (and optionally either forecasted or resampled).- Parameters:
kpi_group – the id of the KPI mapping group
forecast – whether to forecast the proxy time series
resample – whether to resample the proxy time series to the fiscal calendar of the KPI
Examples:
Get the forecasted and resampled version of a proxy time series from the KPI mapping group with numeric ID 123:
kpi_proxy(123)
Get the forecasted proxy time series, without resampling:
kpi_proxy(123, resample=False)
Get the raw proxy time series, without forecasting or resampling:
kpi_proxy(123, forecast=False, resample=False)
- kpi_predictions(*, kpi_group: int, model: int, series: str, run: int, relative_days: int)
Retrieve the KPI predictions from a model.
For each KPI mapping, a prediction for the KPI is produced with a model that only uses the proxy time series as input. These predictions can be retrieved by specifying the KPI mapping group with the
kpi_group
argument.For auto-models or custom models, the revisions can be retrieved by specifying the
model
argument. For these models, when retrieving backtests, the run number can also be specified with therun
argument.The company must be used as the evaluation entity. The signal only works if there is exactly one KPI result belonging to the given company.
- Parameters:
kpi_group – the id of the KPI mapping group
model – the id of the prediction model
series – either “backtests”, “predictions” or “combined”. Defaults to “combined”, which combines the backtests and the live predictions into one time series.
run – the run number to retrieve backtests from. Can only be used with the
model
argument, and withseries
being either “backtests” or “combined”.relative_days – optionally, the number of days the “known time” is relative to the date of the data point. For example, with
relative_days=7
, for each data point you will get the prediction as they were calculated one week after the end of each fiscal period. A negative value will give you known times prior to the end of the fiscal periods.
Examples:
Get the combined predictions from the KPI mapping group with numeric ID 123:
kpi_predictions(kpi_group=123)
Get the combined predictions from the model with numeric ID 123:
kpi_predictions(model=123)
Get the live predictions (without backtests) from the model with numeric ID 123:
kpi_predictions(model=123, series="predictions")
Get the backtests from the model with numeric ID 123:
kpi_predictions(model=123, series="backtests")
- kpi_model_revisions(*, kpi_group: int, model: int, period: str, series: str, values: str | list[str], interval_width: float, error_metric: str, num_periods: int, min_periods: int)
Retrieve the revisions of KPI predictions for a given fiscal period.
For each KPI mapping, a prediction for the KPI is produced with a model that only uses the proxy time series as input. The revisions from these models can be retrieved by specifying the KPI mapping group with the
kpi_group
argument.For auto-models or custom models, the revisions can be retrieved by specifying the
model
argument.The company must be used as the evaluation entity. The signal only works if there is exactly one KPI result belonging to the given company.
- Parameters:
kpi_group – the id of the KPI mapping group
model – the id of the prediction model
period – the name of the period for which revisions should be retrived, for example ‘3Q-2021’, ‘2H-2022’ or ‘FY-2023’, or the last date in the fiscal period, for example ‘2023-09-30’.
series – the kind of time series to return; the options are
predictions
,backtests
andcombined
. In the case ofcombined
, predictions are retrieved first, and if they are not present, the backtests are retrieved. The default iscombined
.values – the time series to return; the options are
prediction
(the predicted values),lower
(the lower confidence band),upper
(the upper confidence band),errors
(the historical errors). The default value is usuallyprediction
, but if theinterval_width
argument is provided, the default value is['prediction', 'lower', 'upper']
interval_width – a number between 0.0 and 1.0 denoting the width of the confidence interval; the default value is 0.95
error_metric – how the errors are calculated; the options are
MAPE
andMAE
. The default isMAPE
.num_periods – the number of fiscal periods to use in order to calculate the errors and the confidence interval. The default is 8.
min_periods – the minimum number of fiscal periods with data required in order for the errors and confidence interval to be calculated. The default is 4. (If it is set to higher than
num_periods
, thennum_periods
is used.)
Examples:
Get the revisions for the prediction of the 2023-09-30 KPI value from the KPI mapping group with numeric ID 123:
kpi_model_revisions(kpi_group=123, period="2023-09-30")
Get the revisions for the prediction of the 3Q-2021 KPI value from the model with numeric ID 123:
kpi_model_revisions(model=123, period="3Q-2021")