From 160af91f9a486c0b205c377e832838e4a4efb656 Mon Sep 17 00:00:00 2001 From: Janne Sinivirta Date: Sat, 24 Feb 2018 18:33:08 +0200 Subject: [PATCH] improving log messages --- freqtrade/exchange/bittrex.py | 8 ++++---- freqtrade/main.py | 17 +++++++---------- freqtrade/rpc/telegram.py | 4 ++-- .../tests/exchange/test_exchange_bittrex.py | 10 +++++----- freqtrade/tests/test_analyze.py | 2 +- 5 files changed, 19 insertions(+), 22 deletions(-) diff --git a/freqtrade/exchange/bittrex.py b/freqtrade/exchange/bittrex.py index 2be81be2d..7d9560a2d 100644 --- a/freqtrade/exchange/bittrex.py +++ b/freqtrade/exchange/bittrex.py @@ -52,7 +52,7 @@ class Bittrex(Exchange): 'MIN_TRADE_REQUIREMENT_NOT_MET', ] if response['message'] in temp_error_messages: - raise ContentDecodingError('Got {}'.format(response['message'])) + raise ContentDecodingError(response['message']) @property def fee(self) -> float: @@ -110,7 +110,7 @@ class Bittrex(Exchange): not all(key in data.get('result', {}) for key in keys) or\ not all(data.get('result', {})[key] is not None for key in keys): raise ContentDecodingError('{message} params=({pair})'.format( - message='Got invalid response from bittrex', + message='Invalid response from Bittrex', pair=pair)) # Update the pair self.cached_ticker[pair] = { @@ -132,14 +132,14 @@ class Bittrex(Exchange): elif tick_interval == 1440: interval = 'Day' else: - raise ValueError('Cannot parse tick_interval: {}'.format(tick_interval)) + raise ValueError('Unknown tick_interval: {}'.format(tick_interval)) data = _API_V2.get_candles(pair.replace('_', '-'), interval) # These sanity check are necessary because bittrex cannot keep their API stable. if not data.get('result'): raise ContentDecodingError('{message} params=({pair})'.format( - message='Got invalid response from bittrex', + message='Invalid response from Bittrex', pair=pair)) for prop in ['C', 'V', 'O', 'H', 'L', 'T']: diff --git a/freqtrade/main.py b/freqtrade/main.py index 52cccbbf1..10cd489b4 100755 --- a/freqtrade/main.py +++ b/freqtrade/main.py @@ -65,10 +65,7 @@ def process_maybe_execute_buy(interval: int) -> bool: if create_trade(float(_CONF['stake_amount']), interval): return True - logger.info( - 'Checked all whitelisted currencies. ' - 'Found no suitable entry positions for buying. Will keep looking ...' - ) + logger.info('Found no buy signals for whitelisted currencies. Trying again..') return False except DependencyException as exception: logger.warning('Unable to create trade: %s', exception) @@ -83,7 +80,7 @@ def process_maybe_execute_sell(trade: Trade, interval: int) -> bool: # Get order details for actual price per unit if trade.open_order_id: # Update trade with order values - logger.info('Got open order for %s', trade) + logger.info('Found open order for %s', trade) trade.update(exchange.get_order(trade.open_order_id)) if trade.is_open and trade.open_order_id is None: @@ -130,16 +127,16 @@ def _process(interval: int, nb_assets: Optional[int] = 0) -> bool: except (requests.exceptions.RequestException, json.JSONDecodeError) as error: logger.warning( - 'Got %s in _process(), retrying in 30 seconds...', + '%s in _process(), retrying in 30 seconds...', error ) time.sleep(30) except OperationalException: - rpc.send_msg('*Status:* Got OperationalException:\n```\n{traceback}```{hint}'.format( + rpc.send_msg('*Status:* OperationalException:\n```\n{traceback}```{hint}'.format( traceback=traceback.format_exc(), hint='Issue `/start` if you think it is safe to restart.' )) - logger.exception('Got OperationalException. Stopping trader ...') + logger.exception('OperationalException. Stopping trader ...') update_state(State.STOPPED) return state_changed @@ -558,9 +555,9 @@ def main(sysargv=sys.argv[1:]) -> int: ) old_state = new_state except KeyboardInterrupt: - logger.info('Got SIGINT, aborting ...') + logger.info('SIGINT received, aborting ...') except BaseException: - logger.exception('Got fatal exception!') + logger.exception('Fatal exception!') finally: cleanup() return 0 diff --git a/freqtrade/rpc/telegram.py b/freqtrade/rpc/telegram.py index ea170baa1..676eba8d7 100644 --- a/freqtrade/rpc/telegram.py +++ b/freqtrade/rpc/telegram.py @@ -425,7 +425,7 @@ def send_msg(msg: str, bot: Bot = None, parse_mode: ParseMode = ParseMode.MARKDO # Sometimes the telegram server resets the current connection, # if this is the case we send the message again. logger.warning( - 'Got Telegram NetworkError: %s! Trying one more time.', + 'Telegram NetworkError: %s! Trying one more time.', network_err.message ) bot.send_message( @@ -433,4 +433,4 @@ def send_msg(msg: str, bot: Bot = None, parse_mode: ParseMode = ParseMode.MARKDO parse_mode=parse_mode, reply_markup=reply_markup ) except TelegramError as telegram_err: - logger.warning('Got TelegramError: %s! Giving up on that message.', telegram_err.message) + logger.warning('TelegramError: %s! Giving up on that message.', telegram_err.message) diff --git a/freqtrade/tests/exchange/test_exchange_bittrex.py b/freqtrade/tests/exchange/test_exchange_bittrex.py index 99a964815..058c25de1 100644 --- a/freqtrade/tests/exchange/test_exchange_bittrex.py +++ b/freqtrade/tests/exchange/test_exchange_bittrex.py @@ -211,14 +211,14 @@ def test_exchange_bittrex_get_ticker_bad(): fb = FakeBittrex() fb.result = {'success': True, 'result': {'Bid': 1, 'Ask': 0}} # incomplete result - with pytest.raises(ContentDecodingError, match=r'.*Got invalid response from bittrex params.*'): + with pytest.raises(ContentDecodingError, match=r'.*Invalid response from Bittrex params.*'): wb.get_ticker('BTC_ETH') fb.result = {'success': False, 'message': 'gone bad'} with pytest.raises(btx.OperationalException, match=r'.*gone bad.*'): wb.get_ticker('BTC_ETH') fb.result = {'success': True, 'result': {}} # incomplete result - with pytest.raises(ContentDecodingError, match=r'.*Got invalid response from bittrex params.*'): + with pytest.raises(ContentDecodingError, match=r'.*Invalid response from Bittrex params.*'): wb.get_ticker('BTC_ETH') fb.result = {'success': False, 'message': 'gone bad'} with pytest.raises(btx.OperationalException, match=r'.*gone bad.*'): @@ -226,7 +226,7 @@ def test_exchange_bittrex_get_ticker_bad(): fb.result = {'success': True, 'result': {'Bid': 1, 'Ask': 0, 'Last': None}} # incomplete result - with pytest.raises(ContentDecodingError, match=r'.*Got invalid response from bittrex params.*'): + with pytest.raises(ContentDecodingError, match=r'.*Invalid response from Bittrex params.*'): wb.get_ticker('BTC_ETH') @@ -242,7 +242,7 @@ def test_exchange_bittrex_get_ticker_history(): wb = make_wrap_bittrex() fb = FakeBittrex() assert wb.get_ticker_history('BTC_ETH', 5) - with pytest.raises(ValueError, match=r'.*Cannot parse tick_interval.*'): + with pytest.raises(ValueError, match=r'.*Unknown tick_interval.*'): wb.get_ticker_history('BTC_ETH', 2) fb.success = False @@ -250,7 +250,7 @@ def test_exchange_bittrex_get_ticker_history(): wb.get_ticker_history('BTC_ETH', 5) fb.success = True - with pytest.raises(ContentDecodingError, match=r'.*Got invalid response from bittrex.*'): + with pytest.raises(ContentDecodingError, match=r'.*Invalid response from Bittrex.*'): fb.result = {'bad': 0} wb.get_ticker_history('BTC_ETH', 5) diff --git a/freqtrade/tests/test_analyze.py b/freqtrade/tests/test_analyze.py index aa685c3df..dc40572b6 100644 --- a/freqtrade/tests/test_analyze.py +++ b/freqtrade/tests/test_analyze.py @@ -104,7 +104,7 @@ def test_get_signal_old_dataframe(default_conf, mocker, caplog): ticks = DataFrame([{'buy': 1, 'date': oldtime}]) mocker.patch('freqtrade.analyze.analyze_ticker', return_value=DataFrame(ticks)) assert (False, False) == get_signal('xyz', int(default_conf['ticker_interval'])) - assert tt.log_has('Too old dataframe for pair xyz', + assert tt.log_has('Too old dataframe for pair xyz. Last ticker is 11 minutes old', caplog.record_tuples)