numeraire.core.engine.backtest_weights#
- numeraire.core.engine.backtest_weights(estimator: Estimator, view: TimeSeriesView, splitter: Any, *, method: str, config: dict[str, Any] | None = None, data_vintage: str = 'unknown', run_id: str | None = None, n_jobs: int = 1, missing_returns: Literal['error', 'zero', 'renormalize_legs'] = 'error') WeightsOutput[source]#
Run a walk-forward OOS backtest of a
to_weightsestimator overview.- Parameters:
estimator – Anything conforming to
Estimator; the fitted model must supportSupportsWeights.splitter – Any object with
split(view) -> Iterator[(train, test)](e.g.WalkForwardSplitter).config – Preprocessing/method config, hashed into every result row’s
config_hash.n_jobs – Fan the independent
(train, test)folds over a thread pool (-1= all cores). Order-preserving, so the result is identical to the serialn_jobs=1default. Each fold fits an isolatedcopy.deepcopyofestimator— never the caller’s instance — so folds stay order- and schedule-independent. The estimator must be deepcopy-able and must not route fit-relevant mutable state around the copy (class attributes, module globals, containers a custom__deepcopy__aliases); an un-copyable resource belongs behind a factory built atfittime.missing_returns – Policy for a non-finite realized return on a non-zero target weight: fail closed (
"error"), explicitly score it as zero ("zero"), or rescale the observed positive and negative legs separately to preserve target exposure ("renormalize_legs").