From 30b72ad98a21f1131e1b7ddb2311ec93007e3915 Mon Sep 17 00:00:00 2001 From: Matthias Date: Tue, 24 Jul 2018 08:20:32 +0100 Subject: [PATCH] don't show fiat-currency if not set --- freqtrade/rpc/telegram.py | 8 +++++--- freqtrade/tests/rpc/test_rpc_telegram.py | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/freqtrade/rpc/telegram.py b/freqtrade/rpc/telegram.py index a63422970..f11fa4232 100644 --- a/freqtrade/rpc/telegram.py +++ b/freqtrade/rpc/telegram.py @@ -125,9 +125,11 @@ class Telegram(RPC): message = "*{exchange}:* Buying [{pair}]({market_url})\n" \ "with limit `{limit:.8f}\n" \ - "({stake_amount:.6f} {stake_currency}," \ - "{stake_amount_fiat:.3f} {fiat_currency})`" \ - .format(**msg) + "({stake_amount:.6f} {stake_currency}".format(**msg) + + if msg.get('fiat_currency', None): + message += ",{stake_amount_fiat:.3f} {fiat_currency}".format(**msg) + message += ")`" elif msg['type'] == RPCMessageType.SELL_NOTIFICATION: msg['amount'] = round(msg['amount'], 8) diff --git a/freqtrade/tests/rpc/test_rpc_telegram.py b/freqtrade/tests/rpc/test_rpc_telegram.py index da4279a06..1ce8a26f1 100644 --- a/freqtrade/tests/rpc/test_rpc_telegram.py +++ b/freqtrade/tests/rpc/test_rpc_telegram.py @@ -1219,12 +1219,12 @@ def test_send_msg_buy_notification_no_fiat(default_conf, mocker) -> None: 'stake_amount': 0.001, 'stake_amount_fiat': 0.0, 'stake_currency': 'BTC', - 'fiat_currency': 'USD' + 'fiat_currency': None }) assert msg_mock.call_args[0][0] \ == '*Bittrex:* Buying [ETH/BTC](https://bittrex.com/Market/Index?MarketName=BTC-ETH)\n' \ 'with limit `0.00001099\n' \ - '(0.001000 BTC,0.000 USD)`' + '(0.001000 BTC)`' def test_send_msg_sell_notification_no_fiat(default_conf, mocker) -> None: