Move "candle" logic for message to telegram

this avoids calling this method unless necessary
This commit is contained in:
Matthias
2022-07-11 14:09:39 +02:00
parent 9a3a2f9013
commit f9d3775d4c
2 changed files with 12 additions and 25 deletions

View File

@@ -861,23 +861,9 @@ 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(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()
})
def _notify_enter_cancel(self, trade: Trade, order_type: str, reason: str) -> None:
"""
Sends rpc notification when a entry order cancel occurred.
@@ -1564,8 +1550,6 @@ class FreqtradeBot(LoggingMixin):
'fiat_currency': self.config['fiat_display_currency'],
})
self._analyzed_candle_to_msg(trade.pair, msg)
# Send the message
self.rpc.send_msg(msg)