mirror of
https://github.com/freqtrade/freqtrade.git
synced 2026-03-01 15:52:43 +00:00
refactor: limit pre-window balance aggregation to equity mode
This commit is contained in:
@@ -54,17 +54,17 @@ class MaxDrawdown(IProtection):
|
||||
if len(trades_in_window) < self._trade_limit:
|
||||
return None
|
||||
|
||||
# Get all trades to calculate cumulative profit before the window
|
||||
all_closed_trades = Trade.get_trades_proxy(is_open=False)
|
||||
profit_before_window = sum(
|
||||
trade.close_profit_abs or 0.0
|
||||
for trade in all_closed_trades
|
||||
if trade.close_date_utc <= look_back_until
|
||||
)
|
||||
|
||||
try:
|
||||
if self._calculation_mode == "equity":
|
||||
# Standard equity-based drawdown
|
||||
# Get all trades to calculate cumulative profit before the window
|
||||
all_closed_trades = Trade.get_trades_proxy(is_open=False)
|
||||
profit_before_window = sum(
|
||||
trade.close_profit_abs or 0.0
|
||||
for trade in all_closed_trades
|
||||
if trade.close_date_utc <= look_back_until
|
||||
)
|
||||
|
||||
trades_df = pd.DataFrame(
|
||||
[
|
||||
{"close_date": t.close_date_utc, "profit_abs": t.close_profit_abs}
|
||||
|
||||
Reference in New Issue
Block a user