Skip to content

skfolio/skfolio-factor-model-class

Rule skfolio-factor-model-class
Pack skfolio
Severity error
Fix unsafe, with xpd check --fix --unsafe-fixes
Library versions skfolio 1.14.4 and later

The skfolio FactorModel dataclass holds fitted results. Fit a TimeSeriesFactorModel prior with the factor matrix in the keyword-only factors argument.

MeanRisk(prior_estimator=FactorModel())
TimeSeriesFactorModel().fit(returns, factor_returns)
MeanRisk(prior_estimator=TimeSeriesFactorModel())
TimeSeriesFactorModel().fit(returns, factors=factor_returns)

To pass factors through an optimizer, request factors on the prior and pass the matrix to the optimizer's fit.

Use xpd check --fix --unsafe-fixes to replace FactorModel() with TimeSeriesFactorModel() and to pass the positional factor matrix as factors=.

xpd prints this message with the issue. A name that starts with $ stands for code from your file.

FactorModel is a fitted skfolio container with 13 required inputs. Use TimeSeriesFactorModel as the prior estimator.

Browse the other rules of the skfolio pack.