From 9982ad2f365b715f8bf2dd225bdcff509c6d8030 Mon Sep 17 00:00:00 2001 From: Matthias Date: Tue, 18 Aug 2020 16:59:24 +0200 Subject: [PATCH] Add profit to backtest summary output --- docs/backtesting.md | 1 + freqtrade/optimize/optimize_reports.py | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/docs/backtesting.md b/docs/backtesting.md index 149d1c104..20e69f52f 100644 --- a/docs/backtesting.md +++ b/docs/backtesting.md @@ -165,6 +165,7 @@ A backtesting result will look like that: | Total trades | 429 | | First trade | 2019-01-01 18:30:00 | | First trade Pair | EOS/USDT | +| Total Profit % | 152.41% | | Trades per day | 3.575 | | Best day | 25.27% | | Worst day | -30.67% | diff --git a/freqtrade/optimize/optimize_reports.py b/freqtrade/optimize/optimize_reports.py index bf4e518ba..0799ebb23 100644 --- a/freqtrade/optimize/optimize_reports.py +++ b/freqtrade/optimize/optimize_reports.py @@ -249,6 +249,9 @@ def generate_backtest_stats(config: Dict, btdata: Dict[str, DataFrame], 'sell_reason_summary': sell_reason_stats, 'left_open_trades': left_open_results, 'total_trades': len(results), + 'profit_mean': results['profit_percent'].mean(), + 'profit_total': results['profit_percent'].sum(), + 'profit_total_abs': results['profit_abs'].sum(), 'backtest_start': min_date.datetime, 'backtest_start_ts': min_date.timestamp * 1000, 'backtest_end': max_date.datetime, @@ -372,6 +375,7 @@ def text_table_add_metrics(strat_results: Dict) -> str: ('Total trades', strat_results['total_trades']), ('First trade', min_trade['open_date'].strftime(DATETIME_PRINT_FORMAT)), ('First trade Pair', min_trade['pair']), + ('Total Profit %', f"{round(strat_results['profit_total'] * 100, 2)}%"), ('Trades per day', strat_results['trades_per_day']), ('Best day', f"{round(strat_results['backtest_best_day'] * 100, 2)}%"), ('Worst day', f"{round(strat_results['backtest_worst_day'] * 100, 2)}%"),