We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 79f3449 commit f6d3d9eCopy full SHA for f6d3d9e
jesse/services/metrics.py
@@ -164,9 +164,8 @@ def realized_max_drawdown(starting_balance, df_pnl):
164
cumulative_balance = starting_balance + df_pnl.cumsum()
165
peak_balance = cumulative_balance.cummax()
166
drawdown = peak_balance - cumulative_balance
167
- max_drawdown = drawdown.max()
168
- peak_at_max_drawdown = peak_balance[drawdown.idxmax()]
169
- result = -(max_drawdown / peak_at_max_drawdown) * 100
+ drawdown_pct = (drawdown / peak_balance) * 100
+ result = -drawdown_pct.max()
170
171
return pd.Series([result])
172
0 commit comments