feat: lookahead-heplpers -> rich table
This commit is contained in:
@@ -4,11 +4,13 @@ from pathlib import Path
|
|||||||
from typing import Any, Dict, List
|
from typing import Any, Dict, List
|
||||||
|
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
|
from rich.text import Text
|
||||||
|
|
||||||
from freqtrade.constants import Config
|
from freqtrade.constants import Config
|
||||||
from freqtrade.exceptions import OperationalException
|
from freqtrade.exceptions import OperationalException
|
||||||
from freqtrade.optimize.analysis.lookahead import LookaheadAnalysis
|
from freqtrade.optimize.analysis.lookahead import LookaheadAnalysis
|
||||||
from freqtrade.resolvers import StrategyResolver
|
from freqtrade.resolvers import StrategyResolver
|
||||||
|
from freqtrade.util import print_rich_table
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@@ -53,17 +55,17 @@ class LookaheadAnalysisSubFunctions:
|
|||||||
[
|
[
|
||||||
inst.strategy_obj["location"].parts[-1],
|
inst.strategy_obj["location"].parts[-1],
|
||||||
inst.strategy_obj["name"],
|
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.total_signals,
|
||||||
inst.current_analysis.false_entry_signals,
|
inst.current_analysis.false_entry_signals,
|
||||||
inst.current_analysis.false_exit_signals,
|
inst.current_analysis.false_exit_signals,
|
||||||
", ".join(inst.current_analysis.false_indicators),
|
", ".join(inst.current_analysis.false_indicators),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
from tabulate import tabulate
|
|
||||||
|
|
||||||
table = tabulate(data, headers=headers, tablefmt="orgtbl")
|
print_rich_table(data, headers, summary="Lookahead Analysis")
|
||||||
print(table)
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ def print_rich_table(
|
|||||||
if isinstance(row, dict):
|
if isinstance(row, dict):
|
||||||
table.add_row(*[str(row[header]) for header in headers])
|
table.add_row(*[str(row[header]) for header in headers])
|
||||||
else:
|
else:
|
||||||
table.add_row(*row)
|
table.add_row(*[r if isinstance(r, Text) else str(r) for r in row])
|
||||||
|
|
||||||
console = Console(
|
console = Console(
|
||||||
width=200 if "pytest" in sys.modules else None,
|
width=200 if "pytest" in sys.modules else None,
|
||||||
|
|||||||
Reference in New Issue
Block a user