From 08803524bd27c8a5c06c4d92cc81b4cf032a9bce Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 12 Feb 2022 15:21:36 +0100 Subject: [PATCH] align variable naming to use current_time --- freqtrade/strategy/interface.py | 11 ++++++----- tests/strategy/test_interface.py | 6 ++++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/freqtrade/strategy/interface.py b/freqtrade/strategy/interface.py index 0bd7834e2..2f3657059 100644 --- a/freqtrade/strategy/interface.py +++ b/freqtrade/strategy/interface.py @@ -687,7 +687,7 @@ class IStrategy(ABC, HyperStrategyMixin): else: return False - def should_sell(self, trade: Trade, rate: float, date: datetime, buy: bool, + def should_sell(self, trade: Trade, rate: float, current_time: datetime, buy: bool, sell: bool, low: float = None, high: float = None, force_stoploss: float = 0) -> SellCheckTuple: """ @@ -704,7 +704,8 @@ class IStrategy(ABC, HyperStrategyMixin): trade.adjust_min_max_rates(high or current_rate, low or current_rate) stoplossflag = self.stop_loss_reached(current_rate=current_rate, trade=trade, - current_time=date, current_profit=current_profit, + current_time=current_time, + current_profit=current_profit, force_stoploss=force_stoploss, low=low, high=high) # Set current rate to high for backtesting sell @@ -714,7 +715,7 @@ class IStrategy(ABC, HyperStrategyMixin): # if buy signal and ignore_roi is set, we don't need to evaluate min_roi. roi_reached = (not (buy and self.ignore_roi_if_buy_signal) and self.min_roi_reached(trade=trade, current_profit=current_profit, - current_time=date)) + current_time=current_time)) sell_signal = SellType.NONE custom_reason = '' @@ -730,8 +731,8 @@ class IStrategy(ABC, HyperStrategyMixin): sell_signal = SellType.SELL_SIGNAL else: custom_reason = strategy_safe_wrapper(self.custom_sell, default_retval=False)( - pair=trade.pair, trade=trade, current_time=date, current_rate=current_rate, - current_profit=current_profit) + pair=trade.pair, trade=trade, current_time=current_time, + current_rate=current_rate, current_profit=current_profit) if custom_reason: sell_signal = SellType.CUSTOM_SELL if isinstance(custom_reason, str): diff --git a/tests/strategy/test_interface.py b/tests/strategy/test_interface.py index fd1c2753f..174ce95c6 100644 --- a/tests/strategy/test_interface.py +++ b/tests/strategy/test_interface.py @@ -437,7 +437,8 @@ def test_stop_loss_reached(default_conf, fee, profit, adjusted, expected, traili strategy.custom_stoploss = custom_stop now = arrow.utcnow().datetime - sl_flag = strategy.stop_loss_reached(current_rate=trade.open_rate * (1 + profit), trade=trade, + current_rate = trade.open_rate * (1 + profit) + sl_flag = strategy.stop_loss_reached(current_rate=current_rate, trade=trade, current_time=now, current_profit=profit, force_stoploss=0, high=None) assert isinstance(sl_flag, SellCheckTuple) @@ -447,8 +448,9 @@ def test_stop_loss_reached(default_conf, fee, profit, adjusted, expected, traili else: assert sl_flag.sell_flag is True assert round(trade.stop_loss, 2) == adjusted + current_rate2 = trade.open_rate * (1 + profit2) - sl_flag = strategy.stop_loss_reached(current_rate=trade.open_rate * (1 + profit2), trade=trade, + sl_flag = strategy.stop_loss_reached(current_rate=current_rate2, trade=trade, current_time=now, current_profit=profit2, force_stoploss=0, high=None) assert sl_flag.sell_type == expected2