robertmartin8 / PyPortfolioOpt

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

What is the right input to EfficientSemivariance? #597

Open codemaniac opened 6 months ago

codemaniac commented 6 months ago

I am confused what is the right input to pass to EfficientSemivariance.

The documentation says Instead of passing in a covariance matrix, you should past in a dataframe of historical/simulated returns (this can be constructed from your price dataframe using the helper method expected_returns.returns_from_prices())

But, the example code uses mu = expected_returns.mean_historical_returns(df) as the first argument to EfficientSemivariance.

By my understanding, expected_returns.returns_from_prices() returns daily percentage change using prices.pct_change() but expected_returns.mean_historical_returns(df) returns annualized returns by default.

Please help! What is the correct input?