From 88ccfedd3235c1f43fc3f728b109ff64b0c3c4db Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 22 Jan 2022 11:50:46 +0100 Subject: [PATCH] Improve wording of "no history found" error --- freqtrade/data/history/idatahandler.py | 13 +++++++------ tests/commands/test_commands.py | 8 ++++---- tests/data/test_history.py | 8 +++++--- tests/optimize/test_backtesting.py | 3 ++- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/freqtrade/data/history/idatahandler.py b/freqtrade/data/history/idatahandler.py index b87912080..31d768a5f 100644 --- a/freqtrade/data/history/idatahandler.py +++ b/freqtrade/data/history/idatahandler.py @@ -248,7 +248,7 @@ class IDataHandler(ABC): timerange=timerange_startup, candle_type=candle_type ) - if self._check_empty_df(pairdf, pair, timeframe, warn_no_data): + if self._check_empty_df(pairdf, pair, timeframe, candle_type, warn_no_data): return pairdf else: enddate = pairdf.iloc[-1]['date'] @@ -256,7 +256,7 @@ class IDataHandler(ABC): if timerange_startup: self._validate_pairdata(pair, pairdf, timeframe, candle_type, timerange_startup) pairdf = trim_dataframe(pairdf, timerange_startup) - if self._check_empty_df(pairdf, pair, timeframe, warn_no_data): + if self._check_empty_df(pairdf, pair, timeframe, candle_type, warn_no_data): return pairdf # incomplete candles should only be dropped if we didn't trim the end beforehand. @@ -265,18 +265,19 @@ class IDataHandler(ABC): fill_missing=fill_missing, drop_incomplete=(drop_incomplete and enddate == pairdf.iloc[-1]['date'])) - self._check_empty_df(pairdf, pair, timeframe, warn_no_data) + self._check_empty_df(pairdf, pair, timeframe, candle_type, warn_no_data) return pairdf - def _check_empty_df(self, pairdf: DataFrame, pair: str, timeframe: str, warn_no_data: bool): + def _check_empty_df(self, pairdf: DataFrame, pair: str, timeframe: str, + candle_type: CandleType, warn_no_data: bool): """ Warn on empty dataframe """ if pairdf.empty: if warn_no_data: logger.warning( - f'No history data for pair: "{pair}", timeframe: {timeframe}. ' - 'Use `freqtrade download-data` to download the data' + f"No history for {pair}, {candle_type}, {timeframe} found. " + "Use `freqtrade download-data` to download the data" ) return True return False diff --git a/tests/commands/test_commands.py b/tests/commands/test_commands.py index 2b5504324..180d11486 100644 --- a/tests/commands/test_commands.py +++ b/tests/commands/test_commands.py @@ -1372,10 +1372,10 @@ def test_start_list_data(testdatadir, capsys): start_list_data(pargs) captured = capsys.readouterr() - assert "Found 3 pair / timeframe combinations." in captured.out - assert "\n| Pair | Timeframe | Type |\n" in captured.out - assert "\n| XRP/USDT | 1h | futures |\n" in captured.out - assert "\n| XRP/USDT | 1h | mark |\n" in captured.out + assert "Found 5 pair / timeframe combinations." in captured.out + assert "\n| Pair | Timeframe | Type |\n" in captured.out + assert "\n| XRP/USDT | 1h | futures |\n" in captured.out + assert "\n| XRP/USDT | 1h, 8h | mark |\n" in captured.out @pytest.mark.usefixtures("init_persistence") diff --git a/tests/data/test_history.py b/tests/data/test_history.py index 349deaa22..ad388a2c8 100644 --- a/tests/data/test_history.py +++ b/tests/data/test_history.py @@ -81,7 +81,7 @@ def test_load_data_7min_timeframe(mocker, caplog, default_conf, testdatadir) -> assert isinstance(ld, DataFrame) assert ld.empty assert log_has( - 'No history data for pair: "UNITTEST/BTC", timeframe: 7m. ' + 'No history for UNITTEST/BTC, spot, 7m found. ' 'Use `freqtrade download-data` to download the data', caplog ) @@ -138,8 +138,8 @@ def test_load_data_with_new_pair_1min(ohlcv_history_list, mocker, caplog, load_pair_history(datadir=tmpdir1, timeframe='1m', pair='MEME/BTC', candle_type=candle_type) assert not file.is_file() assert log_has( - 'No history data for pair: "MEME/BTC", timeframe: 1m. ' - 'Use `freqtrade download-data` to download the data', caplog + f"No history for MEME/BTC, {candle_type}, 1m found. " + "Use `freqtrade download-data` to download the data", caplog ) # download a new pair if refresh_pairs is set @@ -744,6 +744,8 @@ def test_datahandler_ohlcv_get_available_data(testdatadir): ('UNITTEST/USDT', '1h', 'mark'), ('XRP/USDT', '1h', 'futures'), ('XRP/USDT', '1h', 'mark'), + ('XRP/USDT', '8h', 'mark'), + ('XRP/USDT', '8h', 'funding_rate'), } paircombs = JsonGzDataHandler.ohlcv_get_available_data(testdatadir, 'spot') diff --git a/tests/optimize/test_backtesting.py b/tests/optimize/test_backtesting.py index 75bcdffcc..540e963eb 100644 --- a/tests/optimize/test_backtesting.py +++ b/tests/optimize/test_backtesting.py @@ -1171,7 +1171,7 @@ def test_backtest_start_multi_strat_nomock(default_conf, mocker, caplog, testdat @pytest.mark.filterwarnings("ignore:deprecated") def test_backtest_start_nomock_futures(default_conf_usdt, mocker, - caplog, testdatadir, capsys): + caplog, testdatadir, capsys): # Tests detail-data loading default_conf_usdt.update({ "trading_mode": "futures", @@ -1270,6 +1270,7 @@ def test_backtest_start_nomock_futures(default_conf_usdt, mocker, assert 'SELL REASON STATS' in captured.out assert 'LEFT OPEN TRADES REPORT' in captured.out + @pytest.mark.filterwarnings("ignore:deprecated") def test_backtest_start_multi_strat_nomock_detail(default_conf, mocker, caplog, testdatadir, capsys):