skfolio/skfolio-unchecked-failed-portfolio
| Pack | Severity | Fix | Versions |
|---|---|---|---|
| skfolio | info | none, edit by hand | skfolio 1.14.4+ |
With raise_on_failure=False, skfolio can produce a FailedPortfolio with NaN values and a stored error.
book = MeanRisk(raise_on_failure=False).fit(returns).predict(returns)weights = book.weightsbook = MeanRisk(raise_on_failure=False).fit(returns).predict(returns)if isinstance(book, FailedPortfolio): raise RuntimeError(book.optimization_error)weights = book.weightsWhat the rule reports
Section titled “What the rule reports”The rule follows a direct prediction using an explicitly non-raising constructor. During sequential evaluation, inspect failed_portfolios on the result to find failed periods.
Diagnostic message
Section titled “Diagnostic message”skfolio can return FailedPortfolio after optimization fails. The measured failed portfolio had 3 NaN weights. Check for failure before using portfolio values.See all rules in the skfolio pack.