Skip to content

Commit

Permalink
BUG: Replace zeros with NaNs before counting
Browse files Browse the repository at this point in the history
  • Loading branch information
gusgordon committed Feb 11, 2017
1 parent 1181b65 commit bc1a59d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pyfolio/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ def plot_holdings(returns, positions, legend_loc='best', ax=None, **kwargs):
ax = plt.gca()

positions = positions.copy().drop('cash', axis='columns')
df_holdings = positions.apply(lambda x: np.sum(x != 0), axis='columns')
df_holdings = positions.replace(0, np.nan).count(axis=1)
df_holdings_by_month = df_holdings.resample('1M').mean()
df_holdings.plot(color='steelblue', alpha=0.6, lw=0.5, ax=ax, **kwargs)
df_holdings_by_month.plot(
Expand Down

0 comments on commit bc1a59d

Please sign in to comment.