ranaroussi / quantstats

Portfolio analytics for quants, written in Python
Apache License 2.0
4.88k stars 849 forks source link

when rf is not equal to zero, metric report doesn't look correct. #18

Closed sabirjana closed 2 years ago

sabirjana commented 4 years ago

qs.reports.full(stock,benchmark='^NSEI',rf=0.065)

Performance Metrics Strategy Benchmark


Start Period 2014-11-14 2014-11-14 End Period 2019-11-14 2019-11-14 Risk-Free Rate 0.06% 0.06% Time in Market 100.0% 100.0%

Cumulative Return -100.0% -100.0% CAGR% -100.0% -100.0% Sharpe -62.45 -118.52 Sortino -15.39 -15.73

sabirjana commented 4 years ago

Hi, I tried to look into it, seems following are the issues

  1. utils._prepare_returns() invokes to_excess_returns every time wherever rf > 0 which is not right
  2. to_excess_returns() is needed only in few cases such as in case of Sharpe, Sortino etc. and not in all cases when _prepare_returns() is called and rf>0

thank you

sabirjana commented 4 years ago

Hello Ran, do you have any plan to update the master branch for this issue? Thank SJ

brubrant commented 2 years ago

This still happening: if RF is no 0 the reports are buggy...

Zegoverno commented 2 years ago

same here

BartStolarek commented 2 years ago

Still a bug?

ghost commented 2 years ago

You need to adjust the period. In my case it works.

So, if you use monthly returns there is an argument in the function periods_per_year

for example, in this I am using monthly returns. So:

qs.reports.full(portfolio, 'SPY', rf=0.02, periods_per_year=12)

image