From 792d2dbe3222e388f15088cfc6301fb0b0d408de Mon Sep 17 00:00:00 2001 From: Matthias Date: Wed, 10 Oct 2018 21:29:40 +0200 Subject: [PATCH 1/2] Hide "dust" from /balance --- freqtrade/rpc/telegram.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/freqtrade/rpc/telegram.py b/freqtrade/rpc/telegram.py index b6ad047b5..996137728 100644 --- a/freqtrade/rpc/telegram.py +++ b/freqtrade/rpc/telegram.py @@ -307,11 +307,14 @@ class Telegram(RPC): result = self._rpc_balance(self._config.get('fiat_display_currency', '')) output = '' for currency in result['currencies']: - output += "*{currency}:*\n" \ - "\t`Available: {available: .8f}`\n" \ - "\t`Balance: {balance: .8f}`\n" \ - "\t`Pending: {pending: .8f}`\n" \ - "\t`Est. BTC: {est_btc: .8f}`\n".format(**currency) + if currency['est_btc'] > 0.0001: + output += "*{currency}:*\n" \ + "\t`Available: {available: .8f}`\n" \ + "\t`Balance: {balance: .8f}`\n" \ + "\t`Pending: {pending: .8f}`\n" \ + "\t`Est. BTC: {est_btc: .8f}`\n".format(**currency) + else: + output += "*{currency}*: not showing <1$ amount \n".format(**currency) output += "\n*Estimated Value*:\n" \ "\t`BTC: {total: .8f}`\n" \ From 701978a4b1e8ee2238ded16d7a5276957cb05403 Mon Sep 17 00:00:00 2001 From: Matthias Date: Wed, 10 Oct 2018 22:01:22 +0200 Subject: [PATCH 2/2] Add test for dust hiding --- freqtrade/rpc/telegram.py | 2 +- freqtrade/tests/rpc/test_rpc_telegram.py | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/freqtrade/rpc/telegram.py b/freqtrade/rpc/telegram.py index 996137728..040f053f1 100644 --- a/freqtrade/rpc/telegram.py +++ b/freqtrade/rpc/telegram.py @@ -314,7 +314,7 @@ class Telegram(RPC): "\t`Pending: {pending: .8f}`\n" \ "\t`Est. BTC: {est_btc: .8f}`\n".format(**currency) else: - output += "*{currency}*: not showing <1$ amount \n".format(**currency) + output += "*{currency}:* not showing <1$ amount \n".format(**currency) output += "\n*Estimated Value*:\n" \ "\t`BTC: {total: .8f}`\n" \ diff --git a/freqtrade/tests/rpc/test_rpc_telegram.py b/freqtrade/tests/rpc/test_rpc_telegram.py index 182c1d2e7..892c851bd 100644 --- a/freqtrade/tests/rpc/test_rpc_telegram.py +++ b/freqtrade/tests/rpc/test_rpc_telegram.py @@ -507,7 +507,12 @@ def test_telegram_balance_handle(default_conf, update, mocker) -> None: 'total': 10.0, 'free': 10.0, 'used': 0.0 - } + }, + 'XRP': { + 'total': 1.0, + 'free': 1.0, + 'used': 0.0 + } } def mock_ticker(symbol, refresh): @@ -517,7 +522,12 @@ def test_telegram_balance_handle(default_conf, update, mocker) -> None: 'ask': 10000.00, 'last': 10000.00, } - + elif symbol == 'XRP/BTC': + return { + 'bid': 0.00001, + 'ask': 0.00001, + 'last': 0.00001, + } return { 'bid': 0.1, 'ask': 0.1, @@ -548,7 +558,8 @@ def test_telegram_balance_handle(default_conf, update, mocker) -> None: assert '*USDT:*' in result assert 'Balance:' in result assert 'Est. BTC:' in result - assert 'BTC: 14.00000000' in result + assert 'BTC: 12.00000000' in result + assert '*XRP:* not showing <1$ amount' in result def test_balance_handle_empty_response(default_conf, update, mocker) -> None: