From c82e19f5279197327a3eee693e476e8adfec851a Mon Sep 17 00:00:00 2001 From: t Date: Wed, 24 Jan 2018 17:09:19 +0700 Subject: [PATCH] Stop flooding the console with empty balances --- hitbtc/connector.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/hitbtc/connector.py b/hitbtc/connector.py index e807d0b..191c498 100644 --- a/hitbtc/connector.py +++ b/hitbtc/connector.py @@ -148,10 +148,12 @@ def _handle_request_response(self, request, response): # loop over item in response['result'] for: # getSymbols, getTrades, getTradingBalance, getOrders for item in response['result']: - try: - text += msg.format(**item) - except KeyError as e : - print("Formatter for method {} failed on item {} with KeyError {}... item keys {}".format(method, item, e, item.keys())) + # Don't print zero balances + if method is not 'getTradingBalance' or (float(item['available']) > 0 or float(item['reserved']) > 0): + try: + text += msg.format(**item) + except KeyError as e : + print("Formatter for method {} failed on item {} with KeyError {}... item keys {}".format(method, item, e, item.keys())) self.log.info(text) self.echo(text) else: