robertmartin8 / PyPortfolioOpt

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

Compounding of log returns #480

Open Alexander-Shukaev opened 1 year ago

Alexander-Shukaev commented 1 year ago

https://github.com/robertmartin8/PyPortfolioOpt/blob/6644741ff27fca5f2aaeefd63e31d157cfd718ae/pypfopt/expected_returns.py#L145

As a follow up on similar issues from #241, shouldn't log_returns=True affect how compounding is done as per compounding=True? I was under impression that log returns are additive and hence should be compounded by simply adding them together.

Alexander-Shukaev commented 1 year ago

Just to summarize, it feels like compounding=not log_returns produces the expected mathematically correct result.

robertmartin8 commented 1 year ago

Yes, I agree. Honestly I feel that the whole compounding/log returns thing was not very well thought out.

I don't think I should have added support for log returns in the first place. I'm not going to make the breaking change of removing it, but equally I don't want to make the codebase more dirty by having the 2x2 handling of compounding and log_returns.. this would need to be duplicated in every function that supports both parameters.

So for now I will leave this issue up as a reminder/warning of unexpected behaviour, but I don't intend to fix it