From 8928d3616a81a45d8c7084150f67beded55337a7 Mon Sep 17 00:00:00 2001 From: Matthias Date: Fri, 24 Mar 2023 20:47:17 +0100 Subject: [PATCH] Improve msgtypes --- freqtrade/freqtradebot.py | 4 ++++ freqtrade/rpc/rpc_types.py | 8 ++++++++ freqtrade/rpc/telegram.py | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index 7db9c1e30..3aa1075d8 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -973,6 +973,7 @@ class FreqtradeBot(LoggingMixin): 'order_type': order_type, 'stake_amount': trade.stake_amount, 'stake_currency': self.config['stake_currency'], + 'base_currency': self.exchange.get_pair_base_currency(trade.pair), 'fiat_currency': self.config.get('fiat_display_currency', None), 'amount': order.safe_amount_after_fee if fill else (order.amount or trade.amount), 'open_date': trade.open_date or datetime.utcnow(), @@ -1005,6 +1006,7 @@ class FreqtradeBot(LoggingMixin): 'stake_amount': trade.stake_amount, 'open_rate': trade.open_rate, 'stake_currency': self.config['stake_currency'], + 'base_currency': self.exchange.get_pair_base_currency(trade.pair), 'fiat_currency': self.config.get('fiat_display_currency', None), 'amount': trade.amount, 'open_date': trade.open_date, @@ -1695,6 +1697,7 @@ class FreqtradeBot(LoggingMixin): 'close_date': trade.close_date or datetime.utcnow(), 'stake_amount': trade.stake_amount, 'stake_currency': self.config['stake_currency'], + 'base_currency': self.exchange.get_pair_base_currency(trade.pair), 'fiat_currency': self.config.get('fiat_display_currency'), 'sub_trade': sub_trade, 'cumulative_profit': trade.realized_profit, @@ -1747,6 +1750,7 @@ class FreqtradeBot(LoggingMixin): 'open_date': trade.open_date, 'close_date': trade.close_date or datetime.now(timezone.utc), 'stake_currency': self.config['stake_currency'], + 'base_currency': self.exchange.get_pair_base_currency(trade.pair), 'fiat_currency': self.config.get('fiat_display_currency', None), 'reason': reason, 'sub_trade': sub_trade, diff --git a/freqtrade/rpc/rpc_types.py b/freqtrade/rpc/rpc_types.py index 5ddaa0c17..5a3549aa7 100644 --- a/freqtrade/rpc/rpc_types.py +++ b/freqtrade/rpc/rpc_types.py @@ -15,6 +15,12 @@ class RPCStatusMsg(RPCSendMsgBase): status: str +class RPCStrategyMsg(RPCSendMsgBase): + """Used for Status, Startup and Warning messages""" + type: Literal[RPCMessageType.STRATEGY_MSG] + msg: str + + class RPCProtectionMsg(RPCSendMsgBase): type: Literal[RPCMessageType.PROTECTION_TRIGGER, RPCMessageType.PROTECTION_TRIGGER_GLOBAL] id: int @@ -40,6 +46,7 @@ class __RPCBuyMsgBase(RPCSendMsgBase): enter_tag: Optional[str] exchange: str pair: str + base_currency: str leverage: Optional[float] direction: str limit: float @@ -90,6 +97,7 @@ class RPCSellCancelMsg(__RPCBuyMsgBase): RPCSendMsg = Union[ RPCStatusMsg, + RPCStrategyMsg, RPCProtectionMsg, RPCWhitelistMsg, RPCBuyMsg, diff --git a/freqtrade/rpc/telegram.py b/freqtrade/rpc/telegram.py index c1365702d..6f34b7325 100644 --- a/freqtrade/rpc/telegram.py +++ b/freqtrade/rpc/telegram.py @@ -437,7 +437,7 @@ class Telegram(RPCHandler): msg_type = msg['type'] noti = '' - if msg_type == RPCMessageType.EXIT: + if msg['type'] == RPCMessageType.EXIT: sell_noti = self._config['telegram'] \ .get('notification_settings', {}).get(str(msg_type), {}) # For backward compatibility sell still can be string