From c99ae3b41990a0b9a69582d9445ef7aea25e30ed Mon Sep 17 00:00:00 2001 From: barbarius Date: Mon, 28 Jun 2021 10:20:34 +0200 Subject: [PATCH 1/4] Added timerange above multiple strategy backtest result summary table --- freqtrade/optimize/optimize_reports.py | 4 ++++ tests/optimize/test_backtesting.py | 1 + 2 files changed, 5 insertions(+) diff --git a/freqtrade/optimize/optimize_reports.py b/freqtrade/optimize/optimize_reports.py index 922f27fad..52562978b 100644 --- a/freqtrade/optimize/optimize_reports.py +++ b/freqtrade/optimize/optimize_reports.py @@ -660,9 +660,13 @@ def show_backtest_results(config: Dict, backtest_stats: Dict): show_backtest_result(strategy, results, stake_currency) if len(backtest_stats['strategy']) > 1: + backtest_timerange = f"{next(iter(backtest_stats['strategy'].items()))[1]['backtest_start']} -> " \ + f"{next(iter(backtest_stats['strategy'].items()))[1]['backtest_end']}" + # Print Strategy summary table table = text_table_strategy(backtest_stats['strategy_comparison'], stake_currency) + print(backtest_timerange) print(' STRATEGY SUMMARY '.center(len(table.splitlines()[0]), '=')) print(table) print('=' * len(table.splitlines()[0])) diff --git a/tests/optimize/test_backtesting.py b/tests/optimize/test_backtesting.py index ec176bc32..cbc766b78 100644 --- a/tests/optimize/test_backtesting.py +++ b/tests/optimize/test_backtesting.py @@ -993,4 +993,5 @@ def test_backtest_start_multi_strat_nomock(default_conf, mocker, caplog, testdat assert 'BACKTESTING REPORT' in captured.out assert 'SELL REASON STATS' in captured.out assert 'LEFT OPEN TRADES REPORT' in captured.out + assert '2017-11-14 21:17:00 -> 2017-11-14 22:58:00' in captured.out assert 'STRATEGY SUMMARY' in captured.out From 2e5b719de82e52c46e1778845a7571d70f728d62 Mon Sep 17 00:00:00 2001 From: barbarius Date: Mon, 28 Jun 2021 10:54:54 +0200 Subject: [PATCH 2/4] Added timerange above multiple strategy backtest result summary table --- freqtrade/optimize/optimize_reports.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/freqtrade/optimize/optimize_reports.py b/freqtrade/optimize/optimize_reports.py index 52562978b..ad2432c21 100644 --- a/freqtrade/optimize/optimize_reports.py +++ b/freqtrade/optimize/optimize_reports.py @@ -660,8 +660,9 @@ def show_backtest_results(config: Dict, backtest_stats: Dict): show_backtest_result(strategy, results, stake_currency) if len(backtest_stats['strategy']) > 1: - backtest_timerange = f"{next(iter(backtest_stats['strategy'].items()))[1]['backtest_start']} -> " \ - f"{next(iter(backtest_stats['strategy'].items()))[1]['backtest_end']}" + backtest_timerange = \ + f"{next(iter(backtest_stats['strategy'].items()))[1]['backtest_start']} -> " \ + f"{next(iter(backtest_stats['strategy'].items()))[1]['backtest_end']}" # Print Strategy summary table From a0f28f4a15074014851a7d02ab7db03a09f18493 Mon Sep 17 00:00:00 2001 From: barbarius Date: Mon, 28 Jun 2021 17:05:12 +0200 Subject: [PATCH 3/4] Added max open trades to strategy summary first line --- freqtrade/optimize/optimize_reports.py | 8 +++----- tests/optimize/test_backtesting.py | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/freqtrade/optimize/optimize_reports.py b/freqtrade/optimize/optimize_reports.py index ad2432c21..c974916df 100644 --- a/freqtrade/optimize/optimize_reports.py +++ b/freqtrade/optimize/optimize_reports.py @@ -660,14 +660,12 @@ def show_backtest_results(config: Dict, backtest_stats: Dict): show_backtest_result(strategy, results, stake_currency) if len(backtest_stats['strategy']) > 1: - backtest_timerange = \ - f"{next(iter(backtest_stats['strategy'].items()))[1]['backtest_start']} -> " \ - f"{next(iter(backtest_stats['strategy'].items()))[1]['backtest_end']}" - # Print Strategy summary table + first_strat_stats = next(iter(backtest_stats['strategy'].items()))[1] table = text_table_strategy(backtest_stats['strategy_comparison'], stake_currency) - print(backtest_timerange) + print(f"{first_strat_stats['backtest_start']} -> {first_strat_stats['backtest_end']} |" + f" Max open trades : {first_strat_stats['max_open_trades']}") print(' STRATEGY SUMMARY '.center(len(table.splitlines()[0]), '=')) print(table) print('=' * len(table.splitlines()[0])) diff --git a/tests/optimize/test_backtesting.py b/tests/optimize/test_backtesting.py index cbc766b78..30d86f979 100644 --- a/tests/optimize/test_backtesting.py +++ b/tests/optimize/test_backtesting.py @@ -993,5 +993,5 @@ def test_backtest_start_multi_strat_nomock(default_conf, mocker, caplog, testdat assert 'BACKTESTING REPORT' in captured.out assert 'SELL REASON STATS' in captured.out assert 'LEFT OPEN TRADES REPORT' in captured.out - assert '2017-11-14 21:17:00 -> 2017-11-14 22:58:00' in captured.out + assert '2017-11-14 21:17:00 -> 2017-11-14 22:58:00 | Max open trades : 1' in captured.out assert 'STRATEGY SUMMARY' in captured.out From a8117c6e0b67e08fafe9e95c7c0f80931d23cc2b Mon Sep 17 00:00:00 2001 From: barbarius Date: Tue, 29 Jun 2021 11:24:49 +0200 Subject: [PATCH 4/4] Refactored to use results variable from for loop --- freqtrade/optimize/optimize_reports.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/freqtrade/optimize/optimize_reports.py b/freqtrade/optimize/optimize_reports.py index c974916df..79208c5e9 100644 --- a/freqtrade/optimize/optimize_reports.py +++ b/freqtrade/optimize/optimize_reports.py @@ -662,10 +662,9 @@ def show_backtest_results(config: Dict, backtest_stats: Dict): if len(backtest_stats['strategy']) > 1: # Print Strategy summary table - first_strat_stats = next(iter(backtest_stats['strategy'].items()))[1] table = text_table_strategy(backtest_stats['strategy_comparison'], stake_currency) - print(f"{first_strat_stats['backtest_start']} -> {first_strat_stats['backtest_end']} |" - f" Max open trades : {first_strat_stats['max_open_trades']}") + print(f"{results['backtest_start']} -> {results['backtest_end']} |" + f" Max open trades : {results['max_open_trades']}") print(' STRATEGY SUMMARY '.center(len(table.splitlines()[0]), '=')) print(table) print('=' * len(table.splitlines()[0]))