Stacking Optimization

A meta-learning ensemble that combines several base portfolio optimisers into a single allocation through a cross-validated meta-stage. Diversifies model risk across optimisers with different inductive biases - mean-variance, hierarchical, risk-parity, factor - rather than committing the entire portfolio to one structural assumption.

Overview

Stacked generalisation was introduced by Wolpert (1992) and refined by Breiman (1996) as a strategy for combining the predictions of multiple base learners. A held-out fold is used to score each base learner, and a meta-learner then maps the base predictions to a final prediction. The ensemble outperforms the best base learner whenever the base learners make different mistakes - which is exactly the situation in portfolio optimisation, where different optimisers are sensitive to different aspects of the data (means, covariances, correlations, regime structure).

FolioLab implements stacking via skfolio's StackingOptimization over exactly three base estimators, fixed in the code:

  • inv_vol: Inverse Volatility, closed form, no solver.
  • max_div: Maximum Diversification.
  • risk_budget_cvar: Risk Budgeting under the CVaR risk measure.

Neither Mean Variance nor HRP is a base here. The set is not configurable, and no request field adds to it or removes from it. Each base is fit on cross-validated folds of the training data; the meta-stage then learns the convex combination of the three base portfolios. The final allocation is the meta-weighted blend of those three allocations.

The meta-stage in skfolio is itself an optimisation problem, so the whole stack is a two-level convex programme. Cross-validation cross-fits the base returns the meta-stage trains on, so the meta-stage does not read a base portfolio scored on the same rows that fitted it. Read the limits of that in the next paragraph.

The folds are not chronological. The setting is cv=3, which resolves to an ordinary KFold. The folds are cross-fitted but not out of sample in time: a fold can be scored by a base estimator fitted partly on later data. This holds with or without constraints. So the cross-validation removes the simplest form of reuse, and it does not give a walk-forward or out-of-sample reading of how the bases performed.

Mathematical Formulation

Notation

  • - set of base optimisers
  • - weights produced by base on training fold
  • - out-of-fold returns of base on the held-out fold
  • - meta-weights, one per base optimiser

Stage 1: cross-validated base outputs

For each fold and each base optimiser , fit on the training portion of fold , then evaluate the resulting weights on the held-out portion to get the out-of-fold return series . Stack these returns into an matrix of out-of-fold returns.

Stage 2: meta-optimisation

is the covariance of the out-of-fold base-portfolio returns. The meta-stage chooses a long-only convex combination of base portfolios that minimises out-of-fold variance (skfolio also supports CVaR and other risk measures at the meta-stage). This is a low-dimensional QP - is typically 3 to 6 - and is fast.

Final allocation

is the base- portfolio fit on the full training history. The final stacked portfolio is the meta-weighted combination. Long-only and budget constraints on propagate to by convex combination.

Why stacking works

Each of the three base optimisers encodes a structural assumption. Inverse Volatility assumes correlations can be ignored. Maximum Diversification assumes the diversification ratio is the quantity to maximise, so it reads the correlations directly. Risk Budgeting under CVaR assumes equal tail-risk contribution is desirable, and it reads the loss tail rather than the variance. When one assumption fails the corresponding base portfolio degrades. As long as the failures are partly idiosyncratic, the meta-stage can downweight the failing base.

The three bases are deliberately not three flavours of the same idea: one ignores covariance, one is driven by it, and one is driven by the tail. None of them requires an expected-return estimate, so the stack as shipped carries no input at the base level.

Advantages & Limitations

Advantages

  • Model-risk diversification: No single inductive bias dominates.
  • Adaptive blending: Meta-weights adjust to which base is currently working.
  • Convex combination: Constraints on the bases propagate to the stack.
  • Cross-fitted scoring: The meta-stage reads base returns from folds the base was not fitted on, so it does not simply reward the base that fitted its own training rows best.

Limitations

  • Computational cost: base fits per training pass.
  • The folds are not chronological: cv=3 is an ordinary KFold, not a walk-forward split. Walk-forward folds are more honest for time-series data, and they are not what runs here, so the cross-fitted base returns are not out-of-sample returns.
  • Black-box weights: Final weights are harder to attribute to a single rationale.
  • Meta-stage is itself an optimiser: Inherits its own estimation noise.

References

  • Wolpert, D. H. (1992). "Stacked Generalization." Neural Networks, 5(2), 241-259.
  • Breiman, L. (1996). "Stacked Regressions." Machine Learning, 24(1), 49-64.
  • van der Laan, M. J., Polley, E. C., & Hubbard, A. E. (2007). "Super Learner." Statistical Applications in Genetics and Molecular Biology, 6(1).
  • skfolio documentation - skfolio.optimization.StackingOptimization.

Not investment advice. Past performance is not indicative of future results.