diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index fe8bcc89b..bde9ea8aa 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -861,8 +861,15 @@ class FreqtradeBot(LoggingMixin): 'current_rate': current_rate, } + self._analyzed_candle_to_msg(trade.pair, msg) + + # Send the message + self.rpc.send_msg(msg) + + def _analyzed_candle_to_msg(self, pair: str, msg: Dict): + """Msg dict will be enhanced with analyzed_candle if possible.""" # display the candle analyzed in telegram - analyzed_df, _ = self.dataprovider.get_analyzed_dataframe(trade.pair, + analyzed_df, _ = self.dataprovider.get_analyzed_dataframe(pair, self.strategy.timeframe) analyzed_candle = analyzed_df.iloc[-1] if len(analyzed_df) > 0 else None if analyzed_candle is not None: @@ -871,9 +878,6 @@ class FreqtradeBot(LoggingMixin): 'analyzed_candle': candle_columns.to_dict() }) - # Send the message - self.rpc.send_msg(msg) - def _notify_enter_cancel(self, trade: Trade, order_type: str, reason: str) -> None: """ Sends rpc notification when a entry order cancel occurred. @@ -1560,15 +1564,7 @@ class FreqtradeBot(LoggingMixin): 'fiat_currency': self.config['fiat_display_currency'], }) - # display the candle analyzed in telegram - analyzed_df, _ = self.dataprovider.get_analyzed_dataframe(trade.pair, - self.strategy.timeframe) - analyzed_candle = analyzed_df.iloc[-1] if len(analyzed_df) > 0 else None - if analyzed_candle is not None: - candle_columns = analyzed_candle[['date', 'open', 'high', 'low', 'close']] - msg.update({ - 'analyzed_candle': candle_columns.to_dict() - }) + self._analyzed_candle_to_msg(trade.pair, msg) # Send the message self.rpc.send_msg(msg)