diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index 5fb4d92be..945d5b70d 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -922,18 +922,19 @@ class FreqtradeBot(LoggingMixin): analyzed_df, _ = self.dataprovider.get_analyzed_dataframe(trade.pair, self.strategy.timeframe) + (enter, exit_, exit_tag) = self.strategy.get_exit_signal( trade.pair, self.strategy.timeframe, analyzed_df, - is_short=trade.is_short + is_short=trade.is_short, ) logger.debug('checking exit') exit_rate = self.exchange.get_rate( trade.pair, side='exit', is_short=trade.is_short, refresh=True) - enter_tag = # TODO + enter_tag = '' # TODO if self._check_and_execute_exit( trade=trade, exit_rate=exit_rate, @@ -1118,6 +1119,7 @@ class FreqtradeBot(LoggingMixin): exit_=exit_, force_stoploss=self.edge.stoploss(trade.pair) if self.edge else 0, enter_tag=enter_tag, + exit_tag=exit_tag, ) if should_exit.exit_flag: diff --git a/freqtrade/strategy/interface.py b/freqtrade/strategy/interface.py index 838fe8177..f7f3d4cd5 100644 --- a/freqtrade/strategy/interface.py +++ b/freqtrade/strategy/interface.py @@ -120,6 +120,8 @@ class IStrategy(ABC, HyperStrategyMixin): # Definition of plot_config. See plotting documentation for more details. plot_config: Dict = {} + tags: Dict[str, List[str]] = {} + def __init__(self, config: dict) -> None: self.config = config # Dict to determine if analysis is necessary @@ -843,7 +845,8 @@ class IStrategy(ABC, HyperStrategyMixin): def should_exit(self, trade: Trade, rate: float, current_time: datetime, *, enter: bool, exit_: bool, low: float = None, high: float = None, - force_stoploss: float = 0, enter_tag: Optional[str] = None) -> ExitCheckTuple: + force_stoploss: float = 0, enter_tag: Optional[str] = None, + exit_tag: Optional[str]) -> ExitCheckTuple: """ This function evaluates if one of the conditions required to trigger an exit order has been reached, which can either be a stop-loss, ROI or exit-signal. @@ -884,7 +887,10 @@ class IStrategy(ABC, HyperStrategyMixin): current_rate = rate current_profit = trade.calc_profit_ratio(current_rate) - if self.use_exit_signal: + if ((enter_tag in self.tags and exit_tag not in self.tags[enter_tag])): + # sell_profit_only and profit doesn't reach the offset - ignore sell signal + pass + elif self.use_exit_signal: if exit_ and not enter: exit_signal = ExitType.EXIT_SIGNAL else: