From 1d27cbd01f1fff08f5187bc052c56d12c84304a2 Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 28 Feb 2022 19:34:10 +0100 Subject: [PATCH] Simplify leverage_prep interface --- freqtrade/optimize/backtesting.py | 5 ----- freqtrade/persistence/models.py | 4 +++- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/freqtrade/optimize/backtesting.py b/freqtrade/optimize/backtesting.py index eae398010..bde887998 100644 --- a/freqtrade/optimize/backtesting.py +++ b/freqtrade/optimize/backtesting.py @@ -695,17 +695,12 @@ class Backtesting: trading_mode=self.trading_mode, leverage=leverage, interest_rate=interest_rate, - isolated_liq=isolated_liq, orders=[], ) trade.adjust_stop_loss(trade.open_rate, self.strategy.stoploss, initial=True) if self.trading_mode == TradingMode.FUTURES: - if isolated_liq is None: - raise OperationalException( - f'isolated_liq is none for {pair} while trading futures, ' - 'this should never happen') trade.set_isolated_liq(isolated_liq) order = Order( diff --git a/freqtrade/persistence/models.py b/freqtrade/persistence/models.py index 18491d687..2c96248d3 100644 --- a/freqtrade/persistence/models.py +++ b/freqtrade/persistence/models.py @@ -425,11 +425,13 @@ class LocalTrade(): self.stop_loss_pct = -1 * abs(percent) self.stoploss_last_update = datetime.utcnow() - def set_isolated_liq(self, isolated_liq: float): + def set_isolated_liq(self, isolated_liq: Optional[float]): """ Method you should use to set self.liquidation price. Assures stop_loss is not passed the liquidation price """ + if not isolated_liq: + return if self.stop_loss is not None: if self.is_short: self.stop_loss = min(self.stop_loss, isolated_liq)