From ea38b5808139c888e668206773a0860cb721bb29 Mon Sep 17 00:00:00 2001 From: Matthias Date: Thu, 16 Dec 2021 20:18:01 +0100 Subject: [PATCH] Add base_currency to allowed webhook fields closes #6075 --- docs/webhook-config.md | 6 ++++++ freqtrade/rpc/rpc_manager.py | 4 ++++ tests/rpc/test_rpc_telegram.py | 3 +++ 3 files changed, 13 insertions(+) diff --git a/docs/webhook-config.md b/docs/webhook-config.md index 40915c988..c93f9aac8 100644 --- a/docs/webhook-config.md +++ b/docs/webhook-config.md @@ -110,6 +110,7 @@ Possible parameters are: * `open_date` * `stake_amount` * `stake_currency` +* `base_currency` * `fiat_currency` * `order_type` * `current_rate` @@ -128,6 +129,7 @@ Possible parameters are: * `open_date` * `stake_amount` * `stake_currency` +* `base_currency` * `fiat_currency` * `order_type` * `current_rate` @@ -146,6 +148,7 @@ Possible parameters are: * `open_date` * `stake_amount` * `stake_currency` +* `base_currency` * `fiat_currency` * `order_type` * `current_rate` @@ -166,6 +169,7 @@ Possible parameters are: * `profit_amount` * `profit_ratio` * `stake_currency` +* `base_currency` * `fiat_currency` * `sell_reason` * `order_type` @@ -188,6 +192,7 @@ Possible parameters are: * `profit_amount` * `profit_ratio` * `stake_currency` +* `base_currency` * `fiat_currency` * `sell_reason` * `order_type` @@ -210,6 +215,7 @@ Possible parameters are: * `profit_amount` * `profit_ratio` * `stake_currency` +* `base_currency` * `fiat_currency` * `sell_reason` * `order_type` diff --git a/freqtrade/rpc/rpc_manager.py b/freqtrade/rpc/rpc_manager.py index 8085ece94..9f62b9e23 100644 --- a/freqtrade/rpc/rpc_manager.py +++ b/freqtrade/rpc/rpc_manager.py @@ -60,6 +60,10 @@ class RPCManager: } """ logger.info('Sending rpc message: %s', msg) + if 'pair' in msg: + msg.update({ + 'base_currency': self._rpc._freqtrade.exchange.get_pair_base_currency(msg['pair']) + }) for mod in self.registered_modules: logger.debug('Forwarding message to rpc.%s', mod.name) try: diff --git a/tests/rpc/test_rpc_telegram.py b/tests/rpc/test_rpc_telegram.py index 4fda67a4a..5266f498f 100644 --- a/tests/rpc/test_rpc_telegram.py +++ b/tests/rpc/test_rpc_telegram.py @@ -952,6 +952,7 @@ def test_telegram_forcesell_handle(default_conf, update, ticker, fee, 'profit_amount': 6.314e-05, 'profit_ratio': 0.0629778, 'stake_currency': 'BTC', + 'base_currency': 'ETH', 'fiat_currency': 'USD', 'buy_tag': ANY, 'sell_reason': SellType.FORCE_SELL.value, @@ -1016,6 +1017,7 @@ def test_telegram_forcesell_down_handle(default_conf, update, ticker, fee, 'profit_amount': -5.497e-05, 'profit_ratio': -0.05482878, 'stake_currency': 'BTC', + 'base_currency': 'ETH', 'fiat_currency': 'USD', 'buy_tag': ANY, 'sell_reason': SellType.FORCE_SELL.value, @@ -1070,6 +1072,7 @@ def test_forcesell_all_handle(default_conf, update, ticker, fee, mocker) -> None 'profit_amount': -4.09e-06, 'profit_ratio': -0.00408133, 'stake_currency': 'BTC', + 'base_currency': 'ETH', 'fiat_currency': 'USD', 'buy_tag': ANY, 'sell_reason': SellType.FORCE_SELL.value,