Don't surprise people with "after_fill" calls

This commit is contained in:
Matthias 2023-08-14 16:12:04 +02:00
parent fc60c0df19
commit bef5e191a4
2 changed files with 11 additions and 0 deletions

View File

@ -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

View File

@ -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.