numeraire.backtest_weights#

numeraire.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_weights estimator over view.

Parameters:
  • estimator – Anything conforming to Estimator; the fitted model must support SupportsWeights.

  • 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 serial n_jobs=1 default. Each fold fits an isolated copy.deepcopy of estimator — 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 at fit time.

  • 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").