refactor: limit pre-window balance aggregation to equity mode
This commit is contained in:
@@ -54,6 +54,9 @@ class MaxDrawdown(IProtection):
|
|||||||
if len(trades_in_window) < self._trade_limit:
|
if len(trades_in_window) < self._trade_limit:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
try:
|
||||||
|
if self._calculation_mode == "equity":
|
||||||
|
# Standard equity-based drawdown
|
||||||
# Get all trades to calculate cumulative profit before the window
|
# Get all trades to calculate cumulative profit before the window
|
||||||
all_closed_trades = Trade.get_trades_proxy(is_open=False)
|
all_closed_trades = Trade.get_trades_proxy(is_open=False)
|
||||||
profit_before_window = sum(
|
profit_before_window = sum(
|
||||||
@@ -62,9 +65,6 @@ class MaxDrawdown(IProtection):
|
|||||||
if trade.close_date_utc <= look_back_until
|
if trade.close_date_utc <= look_back_until
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
|
||||||
if self._calculation_mode == "equity":
|
|
||||||
# Standard equity-based drawdown
|
|
||||||
trades_df = pd.DataFrame(
|
trades_df = pd.DataFrame(
|
||||||
[
|
[
|
||||||
{"close_date": t.close_date_utc, "profit_abs": t.close_profit_abs}
|
{"close_date": t.close_date_utc, "profit_abs": t.close_profit_abs}
|
||||||
|
|||||||
Reference in New Issue
Block a user