Skip to content

Commit f6d3d9e

Browse files
committed
Fix RMD calculation
1 parent 79f3449 commit f6d3d9e

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

jesse/services/metrics.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,8 @@ def realized_max_drawdown(starting_balance, df_pnl):
164164
cumulative_balance = starting_balance + df_pnl.cumsum()
165165
peak_balance = cumulative_balance.cummax()
166166
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
167+
drawdown_pct = (drawdown / peak_balance) * 100
168+
result = -drawdown_pct.max()
170169

171170
return pd.Series([result])
172171

0 commit comments

Comments
 (0)