From 462c35cf75b180e1cec80909b05a5ee2cf463e91 Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 25 May 2020 20:22:22 +0200 Subject: [PATCH] Move stats generation to the top --- freqtrade/optimize/optimize_reports.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/freqtrade/optimize/optimize_reports.py b/freqtrade/optimize/optimize_reports.py index ea5ed74ba..655f79f78 100644 --- a/freqtrade/optimize/optimize_reports.py +++ b/freqtrade/optimize/optimize_reports.py @@ -249,18 +249,22 @@ def generate_edge_table(results: dict) -> str: def show_backtest_results(config: Dict, btdata: Dict[str, DataFrame], all_results: Dict[str, DataFrame]): for strategy, results in all_results.items(): - - print(f"Result for strategy {strategy}") pair_results = generate_pair_results(btdata, stake_currency=config['stake_currency'], max_open_trades=config['max_open_trades'], results=results, skip_nan=False) + sell_reason_stats = generate_sell_reason_stats(max_open_trades=config['max_open_trades'], + results=results) + left_open_results = generate_pair_results(btdata, stake_currency=config['stake_currency'], + max_open_trades=config['max_open_trades'], + results=results.loc[results['open_at_end']], + skip_nan=True) + # Print results + print(f"Result for strategy {strategy}") table = generate_text_table(pair_results, stake_currency=config['stake_currency']) if isinstance(table, str): print(' BACKTESTING REPORT '.center(len(table.splitlines()[0]), '=')) print(table) - sell_reason_stats = generate_sell_reason_stats(max_open_trades=config['max_open_trades'], - results=results) table = generate_text_table_sell_reason(sell_reason_stats=sell_reason_stats, stake_currency=config['stake_currency'], ) @@ -268,10 +272,6 @@ def show_backtest_results(config: Dict, btdata: Dict[str, DataFrame], print(' SELL REASON STATS '.center(len(table.splitlines()[0]), '=')) print(table) - left_open_results = generate_pair_results(btdata, stake_currency=config['stake_currency'], - max_open_trades=config['max_open_trades'], - results=results.loc[results['open_at_end']], - skip_nan=True) table = generate_text_table(left_open_results, stake_currency=config['stake_currency']) if isinstance(table, str): print(' LEFT OPEN TRADES REPORT '.center(len(table.splitlines()[0]), '='))