Simplify adding candle to message

This commit is contained in:
Matthias 2022-07-11 13:55:32 +02:00
parent 8e8f026ea7
commit 9a3a2f9013

View File

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