Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compatible with pandas 1.2 #671

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyfolio/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ def cone(in_sample_returns (pd.Series),

if factor_returns is not None:
cum_factor_returns = ep.cum_returns(
factor_returns[cum_rets.index], 1.0)
factor_returns.reindex(index=cum_rets.index), 1.0)
cum_factor_returns.plot(lw=2, color='gray',
label=factor_returns.name, alpha=0.60,
ax=ax, **kwargs)
Expand Down
6 changes: 3 additions & 3 deletions pyfolio/round_trips.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ def agg_all_long_short(round_trips, col, stats_dict):
stats_all = (round_trips
.assign(ones=1)
.groupby('ones')[col]
.agg(stats_dict)
.agg(**stats_dict)
.T
.rename(columns={1.0: 'All trades'}))
stats_long_short = (round_trips
.groupby('long')[col]
.agg(stats_dict)
.agg(**stats_dict)
.T
.rename(columns={False: 'Short trades',
True: 'Long trades'}))
Expand Down Expand Up @@ -378,7 +378,7 @@ def gen_round_trip_stats(round_trips):
RETURN_STATS)

stats['symbols'] = \
round_trips.groupby('symbol')['returns'].agg(RETURN_STATS).T
round_trips.groupby('symbol')['returns'].agg(**RETURN_STATS).T

return stats

Expand Down
3 changes: 2 additions & 1 deletion pyfolio/txn.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,5 +202,6 @@ def get_turnover(positions, transactions, denominator='AGB'):

denom.index = denom.index.normalize()
turnover = traded_value.div(denom, axis='index')
turnover = turnover.fillna(0)
with pd.option_context('mode.use_inf_as_na', True):
turnover = turnover.fillna(0)
return turnover