Skip to content

Commit

Permalink
STY used autopep8, minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
eigenfoo authored and twiecki committed Aug 9, 2017
1 parent be18fed commit 7f33410
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion alphalens/performance.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ def factor_alpha_beta(factor_data, long_short=True):
alpha, beta = reg_fit.params

alpha_beta.loc['Ann. alpha', period] = \
(1 + alpha) ** (252.0/period) - 1
(1 + alpha) ** (252.0 / period) - 1
alpha_beta.loc['beta', period] = beta

return alpha_beta
Expand Down
4 changes: 2 additions & 2 deletions alphalens/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ def plot_cumulative_returns(factor_returns, period=1, ax=None):
factor_returns,
period,
# compound returns
lambda ret, period: ((np.nanmean(ret) + 1)**(1./period)) - 1,
lambda ret, period: ((np.nanmean(ret) + 1)**(1. / period)) - 1,
min_periods=1,
args=(period,))

Expand Down Expand Up @@ -773,7 +773,7 @@ def plot_cumulative_returns_by_quantile(quantile_returns, period=1, ax=None):
ret_wide,
period,
# compound returns
lambda ret, period: ((np.nanmean(ret) + 1)**(1./period)) - 1,
lambda ret, period: ((np.nanmean(ret) + 1)**(1. / period)) - 1,
min_periods=1,
args=(period,))

Expand Down
8 changes: 5 additions & 3 deletions alphalens/tears.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def create_returns_tear_sheet(factor_data, long_short=True, by_group=False):
std_err=std_spread_quant,
bandwidth=0.5,
ax=ax_mean_quantile_returns_spread_ts
)
)

if by_group:
mean_return_quantile_group, mean_return_quantile_group_std_err = \
Expand Down Expand Up @@ -417,8 +417,10 @@ def create_event_returns_tear_sheet(factor_data,
"""

before, after = avgretplot
after = max(after,
max(utils.get_forward_returns_columns(factor_data.columns))+1)
after = max(
after, max(
utils.get_forward_returns_columns(
factor_data.columns)) + 1)

avg_cumulative_returns = \
perf.average_cumulative_return_by_quantile(
Expand Down
2 changes: 1 addition & 1 deletion alphalens/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ def rate_of_return(period_ret):
"""
1-period Growth Rate: the average rate of 1-period returns
"""
return period_ret.add(1).pow(1./period_ret.name).sub(1)
return period_ret.add(1).pow(1. / period_ret.name).sub(1)


def std_conversion(period_std):
Expand Down

0 comments on commit 7f33410

Please sign in to comment.