mirror of
https://github.com/freqtrade/freqtrade.git
synced 2026-01-20 14:00:38 +00:00
feat: bt-result to tabulate
This commit is contained in:
@@ -379,8 +379,8 @@ def text_table_add_metrics(strat_results: Dict) -> str:
|
||||
*drawdown_metrics,
|
||||
("Market change", f"{strat_results['market_change']:.2%}"),
|
||||
]
|
||||
print_rich_table(metrics, ["Metric", "Value"], summary="SUMMARY METRICS", justify="left")
|
||||
|
||||
return tabulate(metrics, headers=["Metric", "Value"], tablefmt="orgtbl")
|
||||
else:
|
||||
start_balance = fmt_coin(strat_results["starting_balance"], strat_results["stake_currency"])
|
||||
stake_amount = (
|
||||
@@ -394,7 +394,7 @@ def text_table_add_metrics(strat_results: Dict) -> str:
|
||||
f"Your starting balance was {start_balance}, "
|
||||
f"and your stake was {stake_amount}."
|
||||
)
|
||||
return message
|
||||
print(message)
|
||||
|
||||
|
||||
def _show_tag_subresults(results: Dict[str, Any], stake_currency: str):
|
||||
@@ -439,13 +439,7 @@ def show_backtest_result(
|
||||
days_breakdown_stats=days_breakdown_stats, stake_currency=stake_currency, period=period
|
||||
)
|
||||
|
||||
table = text_table_add_metrics(results)
|
||||
if isinstance(table, str) and len(table) > 0:
|
||||
print(" SUMMARY METRICS ".center(len(table.splitlines()[0]), "="))
|
||||
print(table)
|
||||
|
||||
if isinstance(table, str) and len(table) > 0:
|
||||
print("=" * len(table.splitlines()[0]))
|
||||
text_table_add_metrics(results)
|
||||
|
||||
print()
|
||||
|
||||
|
||||
@@ -15,10 +15,11 @@ def print_rich_table(
|
||||
headers: Sequence[str],
|
||||
summary: Optional[str] = None,
|
||||
*,
|
||||
justify="right",
|
||||
table_kwargs: Optional[Dict[str, Any]] = None,
|
||||
) -> None:
|
||||
table = Table(
|
||||
*[c if isinstance(c, Column) else Column(c, justify="right") for c in headers],
|
||||
*[c if isinstance(c, Column) else Column(c, justify=justify) for c in headers],
|
||||
title=summary,
|
||||
**(table_kwargs or {}),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user