Skip to content

Commit 8af8fca

Browse files
committed
X7: dry/backtest: check if it's under the liquidation level.
1 parent 1f1308d commit 8af8fca

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

NostalgiaForInfinityX7.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class NostalgiaForInfinityX7(IStrategy):
6969
INTERFACE_VERSION = 3
7070

7171
def version(self) -> str:
72-
return "v17.2.664"
72+
return "v17.2.665"
7373

7474
stoploss = -0.99
7575

@@ -11517,13 +11517,21 @@ def confirm_trade_exit(
1151711517
current_time: datetime,
1151811518
**kwargs,
1151911519
) -> bool:
11520+
is_backtest = self.is_backtest_mode()
1152011521
# Allow force exits
1152111522
if exit_reason != "force_exit":
1152211523
if self._should_hold_trade(trade, rate, exit_reason):
1152311524
return False
1152411525
if exit_reason in ["stop_loss", "trailing_stop_loss"]:
1152511526
# log.info(f"[{current_time}] Cancelling {exit_reason} exit for {pair}")
11526-
return False
11527+
is_liquidation = False
11528+
if self.is_futures_mode and is_backtest:
11529+
if (trade.is_short and rate > trade.liquidation_price) or (
11530+
not trade.is_short and rate < trade.liquidation_price
11531+
):
11532+
is_liquidation = True
11533+
if not is_liquidation:
11534+
return False
1152711535
if self.exit_profit_only:
1152811536
profit = 0.0
1152911537
if trade.realized_profit != 0.0:

0 commit comments

Comments
 (0)