From bef5e191a480e64e436f43cc310a46ecd0c550a1 Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 14 Aug 2023 16:12:04 +0200 Subject: [PATCH] Don't surprise people with "after_fill" calls --- freqtrade/resolvers/strategy_resolver.py | 5 +++++ freqtrade/strategy/interface.py | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/freqtrade/resolvers/strategy_resolver.py b/freqtrade/resolvers/strategy_resolver.py index 6f5b6655d..50605af72 100644 --- a/freqtrade/resolvers/strategy_resolver.py +++ b/freqtrade/resolvers/strategy_resolver.py @@ -218,6 +218,11 @@ class StrategyResolver(IResolver): "Please update your strategy to implement " "`populate_indicators`, `populate_entry_trend` and `populate_exit_trend` " "with the metadata argument. ") + + after_fill = 'after_fill' in getfullargspec(strategy.custom_stoploss).args + if after_fill: + strategy._ft_stop_uses_after_fill = True + return strategy @staticmethod diff --git a/freqtrade/strategy/interface.py b/freqtrade/strategy/interface.py index 19092b0f4..cbd241a02 100644 --- a/freqtrade/strategy/interface.py +++ b/freqtrade/strategy/interface.py @@ -720,6 +720,8 @@ class IStrategy(ABC, HyperStrategyMixin): # END - Intended to be overridden by strategy ### + _ft_stop_uses_after_fill = False + def __informative_pairs_freqai(self) -> ListPairsWithTimeframes: """ Create informative-pairs needed for FreqAI @@ -1168,6 +1170,10 @@ class IStrategy(ABC, HyperStrategyMixin): :param low: Low value of this candle, only set in backtesting :param high: High value of this candle, only set in backtesting """ + if after_fill and not self._ft_stop_uses_after_fill: + # Skip if the strategy doesn't support after fill. + return + stop_loss_value = force_stoploss if force_stoploss else self.stoploss # Initiate stoploss with open_rate. Does nothing if stoploss is already set.