skfolio/skfolio-prices-not-returns
| Rule | skfolio-prices-not-returns |
|---|---|
| Pack | skfolio |
| Severity | warning |
| Fix | unsafe, with xpd check --fix --unsafe-fixes |
| Library versions | skfolio 1.14.4 and later |
The skfolio S&P 500, FTSE 100 and Nasdaq loaders return price levels. Optimizers expect period returns.
EqualWeighted().fit(load_sp500_dataset())EqualWeighted().fit(prices_to_returns(load_sp500_dataset()))What the rule reports
Section titled “What the rule reports”The rule follows an unmodified loader result into fit, partial_fit or predict.
How to fix it
Section titled “How to fix it”Use xpd check --fix --unsafe-fixes to wrap the price dataset call in prices_to_returns(...) when prices_to_returns is imported.
Message
Section titled “Message”xpd prints this message with the issue. A name that starts with $ stands for code from your file.
The skfolio dataset loader supplies prices. In a 59-row example of converted prices, an equal-weighted portfolio mean was 0.0003062 compared with 101.7354 when fed levels. Convert prices to returns first.Browse the other rules of the skfolio pack.