dcajasn/Riskfolio-Lib

Negative CAGR

gshen33 opened this issue · 2 comments

Hello Dany, thank you very much for creating a great library for portfolio optimization. One of the issues I am having is that I am getting a negative CAGR no matter what I try for the return stream. While looking at the excel report output, I noticed that The Total Days in Database is negative. Is this a bug?
https://docs.google.com/spreadsheets/d/1DguPG36Twg94SiT3W83UfukKyBK5LopvU6TL596Gs9I/edit#gid=2139351347

Hi @gshen33 your DataFrame must be ordered in ascending order by date. If your index is datetime type you must run the following code: Y.sort_index(ascending=True, inplace=True)
Your DataFrame is ordered in descending order:
image
and must be ordered in ascending order:
image

Got it: thank you very much!