ranaroussi / quantstats

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

reports on weekly returns #202

Open andrew521 opened 2 years ago

andrew521 commented 2 years ago

Is this the proper way to do it?

df['pct_change'] = df['amount'].pct_change() ts = pd.Series(df['pct_change'].values, index=df['date']) # qs.reports.full(ts, "SPY",periods_per_year=52)

The results are completely off:

ts date 2018-05-05 NaN 2018-05-12 NaN 2018-05-19 NaN 2018-05-26 inf 2018-06-02 0.452578

2022-06-18 -0.380034 2022-06-25 0.703945 2022-07-02 -0.178626 2022-07-09 0.265566 2022-07-16 -0.143179 Length: 220, dtype: float64

                       Strategy    Benchmark

Start Period 2018-08-04 2018-08-04 End Period 2022-07-09 2022-07-09 Risk-Free Rate 0.0% 0.0% Time in Market 99.0% 99.0%

Cumulative Return 52,568.68% 54.81% CAGR﹪ 344.62% 10.97% .... Max Drawdown -779.81% -33.4% Longest DD Days 189 189 Volatility (ann.) 1381.78% 45.7% R^2 0.02 0.02 Calmar 0.44 0.33 Skew 5.28 0.03 Kurtosis 34.95 8.06

Expected Daily % 2.89% 0.2% Expected Monthly % 13.07% 0.86% Expected Yearly % 250.2% 9.13% Kelly Criterion 28.76% 16.91% Risk of Ruin 0.0% 0.0% Daily Value-at-Risk -130.58% -4.49% Expected Shortfall (cVaR) -130.58% -4.49%