robertmartin8 / PyPortfolioOpt

Financial portfolio optimisation in python, including classical efficient frontier, Black-Litterman, Hierarchical Risk Parity
https://pyportfolioopt.readthedocs.io/
MIT License
4.51k stars 956 forks source link

xmkt should be calculated from de-meaned x in shinkage to single factor #338

Closed realEthanZou closed 3 years ago

realEthanZou commented 3 years ago

In the original matlab code, the xmkt is calculated from de-meaned x

meanx=mean(x);
x=x-meanx(ones(t,1),:);
xmkt=mean(x')';

(code courtesy of Olivier Ledoit and Michael Wolf, BSD licence)

https://github.com/robertmartin8/PyPortfolioOpt/blob/f2706014bf437e47e1df35c01f191e6bf9309b6d/pypfopt/risk_models.py#L457

robertmartin8 commented 3 years ago

@realEthanZou Good spot. I'll push a fix with the next update