numeraire.core.engine.backtest#

numeraire.core.engine.backtest(estimator: Estimator, view: Any, splitter: Any = None, *, method: str, in_sample: bool = False, **kwargs: Any) WeightsOutput | ForecastOutput | PricingOutput | PanelWeightsOutput[source]#

Backtest estimator over view, dispatching to the right typed driver by capability.

The discoverable entry point over the typed drivers. It routes on two things:

  • which capability the fitted model advertises — capabilities() intersected with {to_weights, to_forecast, to_pricing};

  • the view typeTimeSeriesView vs CrossSectionView.

Dispatch rule (capability + view -> driver -> Output):

in_sample=True selects the single-full-sample-fit pricing path (explanatory in-sample R^2) and requires a to_pricing model. Every other path is walk-forward.

To read the capabilities the model must first be fitted, so backtest does one inspection fit on the full ``view`` and then delegates to the driver (which re-fits per fold / on the full sample as its discipline requires). The extra fit is intentional and cheap relative to a full walk-forward; power users who want to skip it — or who need the precise return type — can call the typed driver (backtest_weights / backtest_forecast / backtest_panel / backtest_pricing / backtest_pricing_in_sample) directly.

A model advertising more than one of the three dispatchable capabilities is ambiguous and raises TypeError — call the specific typed driver in that case. Extra keyword arguments (min_train, window, refit_every, config, data_vintage, run_id, n_jobs, …) are forwarded to the selected driver.