From 0d51383b57fa7a09410bdeab9398e3f2b0b27761 Mon Sep 17 00:00:00 2001 From: Matthias Date: Wed, 1 Apr 2020 20:31:21 +0200 Subject: [PATCH] Format logmessages correctly --- freqtrade/data/history/history_utils.py | 11 +++++++---- tests/data/test_history.py | 8 ++++---- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/freqtrade/data/history/history_utils.py b/freqtrade/data/history/history_utils.py index 27aadc17c..1b51b864c 100644 --- a/freqtrade/data/history/history_utils.py +++ b/freqtrade/data/history/history_utils.py @@ -15,6 +15,7 @@ from freqtrade.data.converter import (ohlcv_to_dataframe, from freqtrade.data.history.idatahandler import IDataHandler, get_datahandler from freqtrade.exceptions import OperationalException from freqtrade.exchange import Exchange +from freqtrade.misc import format_ms_time logger = logging.getLogger(__name__) @@ -271,10 +272,12 @@ def _download_trades_history(exchange: Exchange, if trades and since < trades[-1][0]: # Reset since to the last available point # - 5 seconds (to ensure we're getting all trades) + logger.info(f"Using last trade date -5s - Downloading trades for {pair} " + f"since: {format_ms_time(since)}.") since = trades[-1][0] - (5 * 1000) - logger.debug("Current Start: %s", trades[0][0] if trades else 'None') - logger.debug("Current End: %s", trades[-1][0] if trades else 'None') + logger.debug(f"Current Start: {format_ms_time(trades[0][0]) if trades else 'None'}") + logger.debug(f"Current End: {format_ms_time(trades[-1][0]) if trades else 'None'}") logger.info(f"Current Amount of trades: {len(trades)}") # Default since_ms to 30 days if nothing is given @@ -289,8 +292,8 @@ def _download_trades_history(exchange: Exchange, trades = trades_remove_duplicates(trades) data_handler.trades_store(pair, data=trades) - logger.debug("New Start: %s", trades[0][0]) - logger.debug("New End: %s", trades[-1][0]) + logger.debug(f"New Start: {format_ms_time(trades[0][0])}") + logger.debug(f"New End: {format_ms_time(trades[-1][0])}") logger.info(f"New Amount of trades: {len(trades)}") return True diff --git a/tests/data/test_history.py b/tests/data/test_history.py index 8df968217..072bf00f5 100644 --- a/tests/data/test_history.py +++ b/tests/data/test_history.py @@ -547,18 +547,18 @@ def test_download_trades_history(trades_history, mocker, default_conf, testdatad assert log_has("New Amount of trades: 5", caplog) assert file1.is_file() - # clean files freshly downloaded - _clean_test_file(file1) ght_mock.reset_mock() - since_time = int(trades_history[-2][0] // 1000) + since_time = int(trades_history[-3][0] // 1000) + since_time2 = int(trades_history[-1][0] // 1000) timerange = TimeRange('date', None, since_time, 0) assert _download_trades_history(data_handler=data_handler, exchange=exchange, pair='ETH/BTC', timerange=timerange) assert ght_mock.call_count == 1 # Check this in seconds - since we had to convert to seconds above too. - assert int(ght_mock.call_args_list[0].kwargs['since'] // 1000) == since_time - 5 + assert int(ght_mock.call_args_list[0].kwargs['since'] // 1000) == since_time2 - 5 + # clean files freshly downloaded _clean_test_file(file1) mocker.patch('freqtrade.exchange.Exchange.get_historic_trades',