Merge pull request #5229 from kevinjulian/telegram-balance
compact low balance currencies
This commit is contained in:
commit
eb3ead4930
@ -24,7 +24,7 @@ from freqtrade.__init__ import __version__
|
|||||||
from freqtrade.constants import DUST_PER_COIN
|
from freqtrade.constants import DUST_PER_COIN
|
||||||
from freqtrade.enums import RPCMessageType
|
from freqtrade.enums import RPCMessageType
|
||||||
from freqtrade.exceptions import OperationalException
|
from freqtrade.exceptions import OperationalException
|
||||||
from freqtrade.misc import chunks, round_coin_value
|
from freqtrade.misc import chunks, plural, round_coin_value
|
||||||
from freqtrade.rpc import RPC, RPCException, RPCHandler
|
from freqtrade.rpc import RPC, RPCException, RPCHandler
|
||||||
|
|
||||||
|
|
||||||
@ -598,6 +598,9 @@ class Telegram(RPCHandler):
|
|||||||
"Starting capital: "
|
"Starting capital: "
|
||||||
f"`{self._config['dry_run_wallet']}` {self._config['stake_currency']}.\n"
|
f"`{self._config['dry_run_wallet']}` {self._config['stake_currency']}.\n"
|
||||||
)
|
)
|
||||||
|
total_dust_balance = 0
|
||||||
|
total_dust_currencies = 0
|
||||||
|
curr_output = ''
|
||||||
for curr in result['currencies']:
|
for curr in result['currencies']:
|
||||||
if curr['est_stake'] > balance_dust_level:
|
if curr['est_stake'] > balance_dust_level:
|
||||||
curr_output = (
|
curr_output = (
|
||||||
@ -607,9 +610,9 @@ class Telegram(RPCHandler):
|
|||||||
f"\t`Pending: {curr['used']:.8f}`\n"
|
f"\t`Pending: {curr['used']:.8f}`\n"
|
||||||
f"\t`Est. {curr['stake']}: "
|
f"\t`Est. {curr['stake']}: "
|
||||||
f"{round_coin_value(curr['est_stake'], curr['stake'], False)}`\n")
|
f"{round_coin_value(curr['est_stake'], curr['stake'], False)}`\n")
|
||||||
else:
|
elif curr['est_stake'] <= balance_dust_level:
|
||||||
curr_output = (f"*{curr['currency']}:* not showing <{balance_dust_level} "
|
total_dust_balance += curr['est_stake']
|
||||||
f"{curr['stake']} amount \n")
|
total_dust_currencies += 1
|
||||||
|
|
||||||
# Handle overflowing message length
|
# Handle overflowing message length
|
||||||
if len(output + curr_output) >= MAX_TELEGRAM_MESSAGE_LENGTH:
|
if len(output + curr_output) >= MAX_TELEGRAM_MESSAGE_LENGTH:
|
||||||
@ -618,6 +621,14 @@ class Telegram(RPCHandler):
|
|||||||
else:
|
else:
|
||||||
output += curr_output
|
output += curr_output
|
||||||
|
|
||||||
|
if total_dust_balance > 0:
|
||||||
|
output += (
|
||||||
|
f"*{total_dust_currencies} Other "
|
||||||
|
f"{plural(total_dust_currencies, 'Currency', 'Currencies')} "
|
||||||
|
f"(< {balance_dust_level} {result['stake']}):*\n"
|
||||||
|
f"\t`Est. {result['stake']}: "
|
||||||
|
f"{round_coin_value(total_dust_balance, result['stake'], False)}`\n")
|
||||||
|
|
||||||
output += ("\n*Estimated Value*:\n"
|
output += ("\n*Estimated Value*:\n"
|
||||||
f"\t`{result['stake']}: {result['total']: .8f}`\n"
|
f"\t`{result['stake']}: {result['total']: .8f}`\n"
|
||||||
f"\t`{result['symbol']}: "
|
f"\t`{result['symbol']}: "
|
||||||
|
@ -1762,7 +1762,7 @@ def rpc_balance():
|
|||||||
'total': 0.1,
|
'total': 0.1,
|
||||||
'free': 0.01,
|
'free': 0.01,
|
||||||
'used': 0.0
|
'used': 0.0
|
||||||
},
|
},
|
||||||
'EUR': {
|
'EUR': {
|
||||||
'total': 10.0,
|
'total': 10.0,
|
||||||
'free': 10.0,
|
'free': 10.0,
|
||||||
|
@ -519,12 +519,15 @@ def test_telegram_balance_handle(default_conf, update, mocker, rpc_balance, tick
|
|||||||
assert msg_mock.call_count == 1
|
assert msg_mock.call_count == 1
|
||||||
assert '*BTC:*' in result
|
assert '*BTC:*' in result
|
||||||
assert '*ETH:*' not in result
|
assert '*ETH:*' not in result
|
||||||
assert '*USDT:*' in result
|
assert '*USDT:*' not in result
|
||||||
assert '*EUR:*' in result
|
assert '*EUR:*' not in result
|
||||||
|
assert '*LTC:*' in result
|
||||||
|
assert '*XRP:*' not in result
|
||||||
assert 'Balance:' in result
|
assert 'Balance:' in result
|
||||||
assert 'Est. BTC:' in result
|
assert 'Est. BTC:' in result
|
||||||
assert 'BTC: 12.00000000' in result
|
assert 'BTC: 12.00000000' in result
|
||||||
assert '*XRP:* not showing <0.0001 BTC amount' in result
|
assert "*3 Other Currencies (< 0.0001 BTC):*" in result
|
||||||
|
assert 'BTC: 0.00000309' in result
|
||||||
|
|
||||||
|
|
||||||
def test_balance_handle_empty_response(default_conf, update, mocker) -> None:
|
def test_balance_handle_empty_response(default_conf, update, mocker) -> None:
|
||||||
|
Loading…
Reference in New Issue
Block a user