From 5e88bd231dd0f5d347c2939e04e8ee1646a278ce Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 7 Jul 2024 09:56:49 +0200 Subject: [PATCH] feat: lookahead-heplpers -> rich table --- freqtrade/optimize/analysis/lookahead_helpers.py | 10 ++++++---- freqtrade/util/rich_tables.py | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/freqtrade/optimize/analysis/lookahead_helpers.py b/freqtrade/optimize/analysis/lookahead_helpers.py index b502716dc..a8fb1cd35 100644 --- a/freqtrade/optimize/analysis/lookahead_helpers.py +++ b/freqtrade/optimize/analysis/lookahead_helpers.py @@ -4,11 +4,13 @@ from pathlib import Path from typing import Any, Dict, List import pandas as pd +from rich.text import Text from freqtrade.constants import Config from freqtrade.exceptions import OperationalException from freqtrade.optimize.analysis.lookahead import LookaheadAnalysis from freqtrade.resolvers import StrategyResolver +from freqtrade.util import print_rich_table logger = logging.getLogger(__name__) @@ -53,17 +55,17 @@ class LookaheadAnalysisSubFunctions: [ inst.strategy_obj["location"].parts[-1], inst.strategy_obj["name"], - inst.current_analysis.has_bias, + Text("Yes", style="bold red") + if inst.current_analysis.has_bias + else Text("No", style="bold green"), inst.current_analysis.total_signals, inst.current_analysis.false_entry_signals, inst.current_analysis.false_exit_signals, ", ".join(inst.current_analysis.false_indicators), ] ) - from tabulate import tabulate - table = tabulate(data, headers=headers, tablefmt="orgtbl") - print(table) + print_rich_table(data, headers, summary="Lookahead Analysis") return data @staticmethod diff --git a/freqtrade/util/rich_tables.py b/freqtrade/util/rich_tables.py index 63715b70e..926eba916 100644 --- a/freqtrade/util/rich_tables.py +++ b/freqtrade/util/rich_tables.py @@ -26,7 +26,7 @@ def print_rich_table( if isinstance(row, dict): table.add_row(*[str(row[header]) for header in headers]) else: - table.add_row(*row) + table.add_row(*[r if isinstance(r, Text) else str(r) for r in row]) console = Console( width=200 if "pytest" in sys.modules else None,