Fix stop evaluation sequence to have stop before liquidation

Adjust test to have liquidation above stop
closes #9296
This commit is contained in:
Matthias
2023-10-22 09:24:28 +02:00
parent 9b45bb2e24
commit bbbc8a760c
2 changed files with 5 additions and 5 deletions
+4 -4
View File
@@ -1244,10 +1244,6 @@ class IStrategy(ABC, HyperStrategyMixin):
and trade.liquidation_price <= (high or current_rate) and trade.liquidation_price <= (high or current_rate)
and trade.is_short) and trade.is_short)
if (liq_higher_long or liq_lower_short):
logger.debug(f"{trade.pair} - Liquidation price hit. exit_type=ExitType.LIQUIDATION")
return ExitCheckTuple(exit_type=ExitType.LIQUIDATION)
# evaluate if the stoploss was hit if stoploss is not on exchange # evaluate if the stoploss was hit if stoploss is not on exchange
# in Dry-Run, this handles stoploss logic as well, as the logic will not be different to # in Dry-Run, this handles stoploss logic as well, as the logic will not be different to
# regular stoploss handling. # regular stoploss handling.
@@ -1268,6 +1264,10 @@ class IStrategy(ABC, HyperStrategyMixin):
return ExitCheckTuple(exit_type=exit_type) return ExitCheckTuple(exit_type=exit_type)
if (liq_higher_long or liq_lower_short):
logger.debug(f"{trade.pair} - Liquidation price hit. exit_type=ExitType.LIQUIDATION")
return ExitCheckTuple(exit_type=ExitType.LIQUIDATION)
return ExitCheckTuple(exit_type=ExitType.NONE) return ExitCheckTuple(exit_type=ExitType.NONE)
def min_roi_reached_entry(self, trade_dur: int) -> Tuple[Optional[int], Optional[float]]: def min_roi_reached_entry(self, trade_dur: int) -> Tuple[Optional[int], Optional[float]]:
+1 -1
View File
@@ -422,7 +422,7 @@ def test_min_roi_reached3(default_conf, fee) -> None:
# enable custom stoploss, expected after 1st call, expected after 2nd call # enable custom stoploss, expected after 1st call, expected after 2nd call
(0.2, 0.9, ExitType.NONE, None, False, False, 0.3, 0.9, ExitType.NONE, None), (0.2, 0.9, ExitType.NONE, None, False, False, 0.3, 0.9, ExitType.NONE, None),
(0.2, 0.9, ExitType.NONE, None, False, False, -0.2, 0.9, ExitType.STOP_LOSS, None), (0.2, 0.9, ExitType.NONE, None, False, False, -0.2, 0.9, ExitType.STOP_LOSS, None),
(0.2, 0.9, ExitType.NONE, 0.8, False, False, -0.2, 0.9, ExitType.LIQUIDATION, None), (0.2, 0.9, ExitType.NONE, 0.92, False, False, -0.09, 0.9, ExitType.LIQUIDATION, None),
(0.2, 1.14, ExitType.NONE, None, True, False, 0.05, 1.14, ExitType.TRAILING_STOP_LOSS, (0.2, 1.14, ExitType.NONE, None, True, False, 0.05, 1.14, ExitType.TRAILING_STOP_LOSS,
None), None),
(0.01, 0.96, ExitType.NONE, None, True, False, 0.05, 1, ExitType.NONE, None), (0.01, 0.96, ExitType.NONE, None, True, False, 0.05, 1, ExitType.NONE, None),