From 7fe8b7661d7cfe64129c78082622f8e4e9744599 Mon Sep 17 00:00:00 2001 From: Surfer Admin Date: Tue, 31 May 2022 15:46:43 -0400 Subject: [PATCH] Display the signal candle analyzed in telegram. --- freqtrade/freqtradebot.py | 20 ++++++++++++++++++++ freqtrade/rpc/telegram.py | 8 ++++++++ 2 files changed, 28 insertions(+) diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index fba63459b..a9e15d972 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -852,6 +852,16 @@ class FreqtradeBot(LoggingMixin): 'current_rate': current_rate, } + # 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_json(date_unit='s', date_format='iso') + }) + # Send the message self.rpc.send_msg(msg) @@ -1540,6 +1550,16 @@ 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_json(date_unit='s', date_format='iso') + }) + # Send the message self.rpc.send_msg(msg) diff --git a/freqtrade/rpc/telegram.py b/freqtrade/rpc/telegram.py index 4a274002e..8364578a4 100644 --- a/freqtrade/rpc/telegram.py +++ b/freqtrade/rpc/telegram.py @@ -241,6 +241,8 @@ class Telegram(RPCHandler): f" {entry_side['entered'] if is_fill else entry_side['enter']} {msg['pair']}" f" (#{msg['trade_id']})\n" ) + if msg.get('analyzed_candle'): + message += f"*Analyzed Candle:* `{msg['analyzed_candle']}`\n" message += f"*Enter Tag:* `{msg['enter_tag']}`\n" if msg.get('enter_tag', None) else "" message += f"*Amount:* `{msg['amount']:.8f}`\n" if msg.get('leverage') and msg.get('leverage', 1.0) != 1.0: @@ -288,6 +290,12 @@ class Telegram(RPCHandler): message = ( f"{msg['emoji']} *{msg['exchange']}:* " f"{'Exited' if is_fill else 'Exiting'} {msg['pair']} (#{msg['trade_id']})\n" + ) + if not is_fill and msg.get('analyzed_candle'): + message += ( + f"*Analyzed Candle:* `{msg['analyzed_candle']}`\n" + ) + message += ( f"*{'Profit' if is_fill else 'Unrealized Profit'}:* " f"`{msg['profit_ratio']:.2%}{msg['profit_extra']}`\n" f"*Enter Tag:* `{msg['enter_tag']}`\n"