From ab154fce733aa2d4637e32411c65f95cf2462e17 Mon Sep 17 00:00:00 2001 From: ran Date: Thu, 28 Apr 2022 15:18:57 +0100 Subject: [PATCH] Added information ratio to reports --- CHANGELOG.rst | 4 ++++ quantstats/reports.py | 8 ++++++++ quantstats/stats.py | 2 +- quantstats/version.py | 2 +- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index c2322b1b..0aa147e9 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,10 @@ Change Log =========== +0.0.53 +------ +- Added information ratio to reports + 0.0.52 ------ - Added Treynor ratio diff --git a/quantstats/reports.py b/quantstats/reports.py index 7b66af33..0fb40d93 100644 --- a/quantstats/reports.py +++ b/quantstats/reports.py @@ -451,6 +451,8 @@ def metrics(returns, benchmark=None, rf=0., display=True, metrics['Volatility (ann.) %'] = [ret_vol, bench_vol] metrics['R^2'] = _stats.r_squared( df['returns'], df['benchmark'], prepare_returns=False) + metrics['Information Ratio'] = _stats.information_ratio( + df['returns'], df['benchmark'], prepare_returns=False) else: metrics['Volatility (ann.) %'] = [ret_vol] @@ -616,6 +618,12 @@ def metrics(returns, benchmark=None, rf=0., display=True, if not sep: metrics = metrics[metrics.index != ''] + + # remove spaces from column names + metrics = metrics.T + metrics.columns = [c.replace(' %', '').replace(' *int', '').strip() for c in metrics.columns] + metrics = metrics.T + return metrics diff --git a/quantstats/stats.py b/quantstats/stats.py index fdcb8b81..9e654c69 100644 --- a/quantstats/stats.py +++ b/quantstats/stats.py @@ -906,7 +906,7 @@ def rolling_greeks(returns, benchmark, periods=252, prepare_returns=True): return _pd.DataFrame(index=returns.index, data={ "beta": beta, "alpha": alpha - }).fillna(0) + }) def compare(returns, benchmark, aggregate=None, compounded=True, diff --git a/quantstats/version.py b/quantstats/version.py index bf71543f..4ced5aa4 100644 --- a/quantstats/version.py +++ b/quantstats/version.py @@ -1 +1 @@ -version = "0.0.52" +version = "0.0.53"