numeraire.adapters.skfolio_adapter#
skfolio adapter — wrap a skfolio portfolio optimizer as a numeraire to_weights estimator.
skfolio (BSD-3) provides mean-risk / hierarchical-risk-parity /
risk-budgeting optimizers as scikit-learn estimators. This adapter makes one conform to the
numeraire Estimator / Model protocol so it plugs into the walk-forward engine as a peer of
any native method — without adopting skfolio’s own cross-validation or walk-forward machinery
(numeraire owns the out-of-sample loop).
The contract (why this stays leak-free):
fit(view)fits the skfolio estimator onview.returns_frame()— the exact training window the engine hands it — and stores the fittedweights_.to_weights(view)broadcasts those fitted weights across the view’s calendar. It never callsestimator.predict(X_test): skfolio’spredictscores a weight vector on the returns it is given, so feeding it the test window would pour realized test returns into the position — a structural look-ahead. Weights come only from.weights_(a function of the fit window).
Through backtest_weights the estimator is re-fit at each origin on that origin’s PIT window and
the resulting weights are applied to the next period, so the broadcast is per-origin and
point-in-time.
The optional window caps the lookback to the most recent window rows of whatever the engine
hands fit (e.g. a rolling estimation window under an expanding split).
skfolio is an optional dependency (the [skfolio] extra); it is imported lazily inside
fit so this module imports with or without it installed.
Adapt a skfolio optimizer to numeraire |