Skip to content
ToolsOpen sourceBSD-3-Clause

skfolio

Portfolio optimisation built on the scikit-learn API, with proper cross-validation

By skfolio

Sources and offline checks ·

Workflow and limitations

skfolio is a Python library for portfolio optimization and risk analysis using scikit-learn-style estimators. We reviewed its v1.12.9 sources and ran a small offline constraint example with invented data.

What does skfolio optimize?

It fits portfolio-construction models to supplied data and produces weights. Our example minimizes variance across four fictional asset columns. That objective does not decide an investor’s goals: without our additional policy constraints, the result assigns about 99.72% to the artificial low-variance cash proxy.

What do I need to reproduce this example?

Python 3.12, skfolio 1.12.9 and the pinned dependencies in the evidence packet. The input is a numeric returns DataFrame with named columns. We used CLARABEL and 240 artificial observations; no API key, broker credentials or paid data are needed for this packet. A constant cash column is rejected by the tested default covariance estimator.

Which investment-policy rules can be expressed?

The tested MeanRisk interface accepts lower and upper weights and linear constraints. We encoded 55–65% equities, 25–35% bonds, 5–15% cash and a 45% cap per instrument. Percentages use total portfolio value. These are arbitrary teaching limits, not recommended allocations.

Does the example resolve the companies inside equity funds?

No. The optimizer receives one return column per instrument. A separate exact-arithmetic checker combines our invented fund constituents with a direct stock position and tests a 10% issuer limit measured against equity value. No live fund-data lookup or skfolio–Investboard connection was tested.

What happens when the rules contradict one another?

With only two equity funds, a 20% cap on each cannot meet a 55% combined equity floor. The tested model raises ConvexOptimizationError with an infeasible diagnosis. The reproduction script records this failure and does not silently loosen the constraints.

Review scope: Source review plus two successful offline fits and two recorded failure cases at pinned versions. All portfolio values, assets, fund contents and return observations are invented. This is not a backtest, model evaluation, execution test or recommendation. Snapshot age, issuer look-through and human approval are not enforced by the fitted weight model.

Reviewed README · 772109053763

Download version record and notes (JSON)

Compare approaches

  • PyPortfolioOpt — Compare another Python portfolio-optimization library and its own constraints and solver behavior.
  • Riskfolio-Lib — Compare a separate portfolio-construction toolkit; we did not run it in this experiment.

Executed offline · November 12, 2026

The same data, explicit constraints

Our fictional portfolio totals €100,000. Using skfolio 1.12.9 and CLARABEL, we fitted two minimum-variance models to the same 240 artificial return observations. The second model adds equity, bond and cash limits and a 45% cap per instrument.

Fictional instrument

GLOBAL_EQUITY

Starting weight
40.00 %
Without policy constraints
0.01 %
With numerical rules
45.00 %

Fictional instrument

REGIONAL_EQUITY

Starting weight
20.00 %
Without policy constraints
0.01 %
With numerical rules
10.00 %

Fictional instrument

BONDS

Starting weight
30.00 %
Without policy constraints
0.26 %
With numerical rules
30.00 %

Fictional instrument

CASH

Starting weight
10.00 %
Without policy constraints
99.72 %
With numerical rules
15.00 %

Without those policy constraints, about 99.72% goes to the very low-variance artificial cash proxy. This follows from the constructed data and objective; it is not an allocation recommendation. The constrained output satisfies the encoded weight bounds within a tolerance of 0.000001.

Two failure cases are recorded too

  • A constant cash series is rejected by the tested default covariance estimator with NonPositiveVarianceError. The comparison therefore uses a cash proxy with small artificial variation.
  • A 55% equity floor cannot be met when each of the two equity funds is capped at 20%. CLARABEL reports infeasibility; the example does not relax the rules automatically.

The weight optimization does not check fund constituents, snapshot age or human approval. The separate reference checker handles the data rules in the example. No market returns, model responses or broker connections were evaluated.

For a separate product view of holdings beside an investment plan, explore the Investboard demo. David Bartas runs InvestingStack and founded Investboard. This example was not imported into or connected to Investboard.

Live GitHub metrics

Live GitHub data · Nov 27, 2026
Stars
2,678
Stars · 7d
+17
Stars · 30d
+122
30d momentum
+4.8%
Forks
322
Open issues
41
Language
Python
Last push
today

Latest release v1.15.0 on Nov 27, 2026. Repository created Dec 14, 2023.

2.5k2.6k2.7kOct 8Nov 27
Cumulative GitHub stars, Oct 8, 2026 to Nov 27, 2026. Source: InvestingStack daily snapshots.

What it is

skfolio brings scikit-learn conventions (estimators, pipelines, model selection) to portfolio construction, which makes it natural to evaluate allocation models out of sample instead of fitting them to one history.

In the maintainers' words: “Python library for portfolio optimization, factor model construction, and risk management built on scikit-learn”

Tags

  • Portfolio optimisation
  • scikit-learn
  • Cross-validation
  • #asset-allocation
  • #backtesting
  • #factor-investing
  • #factor-models
  • #investing
  • #investment-analysis
  • #portfolio
  • #portfolio-analysis