From 4f1179d85c3d3aa11a76768c8aaa6af922157e96 Mon Sep 17 00:00:00 2001 From: Matthias Date: Thu, 20 Aug 2020 19:56:41 +0200 Subject: [PATCH] Test for empty case --- freqtrade/optimize/optimize_reports.py | 1 - tests/optimize/test_optimize_reports.py | 8 ++++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/freqtrade/optimize/optimize_reports.py b/freqtrade/optimize/optimize_reports.py index 0681eed7b..94729b6a5 100644 --- a/freqtrade/optimize/optimize_reports.py +++ b/freqtrade/optimize/optimize_reports.py @@ -31,7 +31,6 @@ def store_backtest_stats(recordfilename: Path, stats: Dict[str, DataFrame]) -> N recordfilename.parent, f'{recordfilename.stem}-{datetime.now().strftime("%Y-%m-%d_%H-%M-%S")}' ).with_suffix(recordfilename.suffix) - print(stats) file_dump_json(filename, stats) latest_filename = Path.joinpath(filename.parent, LAST_BT_RESULT_FN) diff --git a/tests/optimize/test_optimize_reports.py b/tests/optimize/test_optimize_reports.py index e5d98ca43..4f62e2e23 100644 --- a/tests/optimize/test_optimize_reports.py +++ b/tests/optimize/test_optimize_reports.py @@ -204,6 +204,14 @@ def test_generate_daily_stats(testdatadir): assert res['winner_holding_avg'] == timedelta(seconds=1440) assert res['loser_holding_avg'] == timedelta(days=1, seconds=21420) + # Select empty dataframe! + res = generate_daily_stats(bt_data.loc[bt_data['open_date'] == '2000-01-01', :]) + assert isinstance(res, dict) + assert round(res['backtest_best_day'], 4) == 0.0 + assert res['winning_days'] == 0 + assert res['draw_days'] == 0 + assert res['losing_days'] == 0 + def test_text_table_sell_reason(default_conf):