From 567211e9f9e14f5722fea74686ca45d09c5fb759 Mon Sep 17 00:00:00 2001 From: Matthias Date: Thu, 20 Sep 2018 20:35:26 +0200 Subject: [PATCH] don't print "NAN" lines in "left_open_trades" --- freqtrade/optimize/backtesting.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/freqtrade/optimize/backtesting.py b/freqtrade/optimize/backtesting.py index d0b70afc7..0983ec677 100644 --- a/freqtrade/optimize/backtesting.py +++ b/freqtrade/optimize/backtesting.py @@ -108,7 +108,8 @@ class Backtesting(object): return min(timeframe, key=operator.itemgetter(0))[0], \ max(timeframe, key=operator.itemgetter(1))[1] - def _generate_text_table(self, data: Dict[str, Dict], results: DataFrame) -> str: + def _generate_text_table(self, data: Dict[str, Dict], results: DataFrame, + skip_nan: bool = False) -> str: """ Generates and returns a text table for the given backtest data and the results dataframe :return: pretty printed table with tabulate as str @@ -121,6 +122,9 @@ class Backtesting(object): 'total profit ' + stake_currency, 'avg duration', 'profit', 'loss'] for pair in data: result = results[results.pair == pair] + if skip_nan and result.profit_abs.isnull().all(): + continue + tabular_data.append([ pair, len(result.index), @@ -404,7 +408,7 @@ class Backtesting(object): print(self._generate_text_table_sell_reason(data, results)) print(' LEFT OPEN TRADES REPORT '.center(119, '=')) - print(self._generate_text_table(data, results.loc[results.open_at_end])) + print(self._generate_text_table(data, results.loc[results.open_at_end], True)) print() if len(all_results) > 1: # Print Strategy summary table