Skip to content

Commit 96a1c7e

Browse files
author
Gerry Manoim
committed
Style
1 parent d074b39 commit 96a1c7e

File tree

4 files changed

+284
-259
lines changed

4 files changed

+284
-259
lines changed

alphalens/performance.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -346,13 +346,12 @@ def cumulative_returns(returns):
346346
2015-01-05 1.001310
347347
2015-01-06 1.000805
348348
2015-01-07 1.001092
349-
2015-01-08 0.999200
349+
2015-01-08 0.999200
350350
"""
351351

352352
return ep.cum_returns(returns, starting_value=1)
353353

354354

355-
356355
def positions(weights, period, freq=None):
357356
"""
358357
Builds net position values time series, the portfolio percentage invested
@@ -845,7 +844,9 @@ def average_cumulative_return(q_fact, demean_by):
845844
all_returns = []
846845
for group, g_data in factor_data.groupby('group'):
847846
g_fq = g_data['factor_quantile']
848-
avgcumret = g_fq.groupby(g_fq).apply(cumulative_return, g_fq)
847+
avgcumret = g_fq.groupby(g_fq).apply(
848+
cumulative_return_around_event, g_fq
849+
)
849850
all_returns.append(avgcumret)
850851
q_returns = pd.concat(all_returns, axis=1)
851852
q_returns = pd.DataFrame({'mean': q_returns.mean(axis=1),

alphalens/plotting.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -711,10 +711,10 @@ def plot_monthly_ic_heatmap(mean_monthly_ic, ax=None):
711711
return ax
712712

713713

714-
def plot_cumulative_returns(factor_returns,
714+
def plot_cumulative_returns(factor_returns,
715715
period,
716-
freq=None,
717-
title=None,
716+
freq=None,
717+
title=None,
718718
ax=None):
719719
"""
720720
Plots the cumulative returns of the returns series passed in.
@@ -793,7 +793,6 @@ def plot_cumulative_returns_by_quantile(quantile_returns,
793793

794794
cum_ret = ret_wide.apply(perf.cumulative_returns)
795795

796-
797796
cum_ret = cum_ret.loc[:, ::-1] # we want negative quantiles as 'red'
798797

799798
cum_ret.plot(lw=2, ax=ax, cmap=cm.coolwarm)

0 commit comments

Comments
 (0)