skfolio/skfolio-unchecked-failed-portfolio
| Rule | skfolio-unchecked-failed-portfolio |
|---|---|
| Pack | skfolio |
| Severity | info |
| Fix | none, edit by hand |
| Library versions | skfolio 1.14.4 and later |
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.
Message
Section titled “Message”xpd prints this message with the issue. A name that starts with $ stands for code from your file.
skfolio can return FailedPortfolio after optimization fails. The measured failed portfolio had 3 NaN weights. Check for failure before using portfolio values.Browse the other rules of the skfolio pack.