Skip to content

Commit

Permalink
Style
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerry Manoim committed Mar 10, 2020
1 parent d074b39 commit 96a1c7e
Show file tree
Hide file tree
Showing 4 changed files with 284 additions and 259 deletions.
7 changes: 4 additions & 3 deletions alphalens/performance.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,13 +346,12 @@ def cumulative_returns(returns):
2015-01-05 1.001310
2015-01-06 1.000805
2015-01-07 1.001092
2015-01-08 0.999200
2015-01-08 0.999200
"""

return ep.cum_returns(returns, starting_value=1)



def positions(weights, period, freq=None):
"""
Builds net position values time series, the portfolio percentage invested
Expand Down Expand Up @@ -845,7 +844,9 @@ def average_cumulative_return(q_fact, demean_by):
all_returns = []
for group, g_data in factor_data.groupby('group'):
g_fq = g_data['factor_quantile']
avgcumret = g_fq.groupby(g_fq).apply(cumulative_return, g_fq)
avgcumret = g_fq.groupby(g_fq).apply(
cumulative_return_around_event, g_fq
)
all_returns.append(avgcumret)
q_returns = pd.concat(all_returns, axis=1)
q_returns = pd.DataFrame({'mean': q_returns.mean(axis=1),
Expand Down
7 changes: 3 additions & 4 deletions alphalens/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -711,10 +711,10 @@ def plot_monthly_ic_heatmap(mean_monthly_ic, ax=None):
return ax


def plot_cumulative_returns(factor_returns,
def plot_cumulative_returns(factor_returns,
period,
freq=None,
title=None,
freq=None,
title=None,
ax=None):
"""
Plots the cumulative returns of the returns series passed in.
Expand Down Expand Up @@ -793,7 +793,6 @@ def plot_cumulative_returns_by_quantile(quantile_returns,

cum_ret = ret_wide.apply(perf.cumulative_returns)


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

cum_ret.plot(lw=2, ax=ax, cmap=cm.coolwarm)
Expand Down
Loading

0 comments on commit 96a1c7e

Please sign in to comment.