From 78194559f4cc2319e8407688fda93b0d35237474 Mon Sep 17 00:00:00 2001 From: Sam Germain Date: Sat, 26 Feb 2022 08:07:01 -0600 Subject: [PATCH] persistence.adjust_stop_loss accounts for leverage --- freqtrade/persistence/models.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/freqtrade/persistence/models.py b/freqtrade/persistence/models.py index 18491d687..ae4265374 100644 --- a/freqtrade/persistence/models.py +++ b/freqtrade/persistence/models.py @@ -566,13 +566,14 @@ class LocalTrade(): # Don't modify if called with initial and nothing to do return + leverage = self.leverage or 1.0 if self.is_short: - new_loss = float(current_price * (1 + abs(stoploss))) + new_loss = float(current_price * (1 + abs(stoploss / leverage))) # If trading with leverage, don't set the stoploss below the liquidation price if self.isolated_liq: new_loss = min(self.isolated_liq, new_loss) else: - new_loss = float(current_price * (1 - abs(stoploss))) + new_loss = float(current_price * (1 - abs(stoploss / leverage))) # If trading with leverage, don't set the stoploss below the liquidation price if self.isolated_liq: new_loss = max(self.isolated_liq, new_loss)