Implement colors for hyperopt-output

This commit is contained in:
Matthias
2024-07-07 16:28:02 +02:00
parent 8f0ac0aaea
commit 4d6f399131
+14 -6
View File
@@ -56,8 +56,9 @@ class HyperoptOutput:
"""Format one or multiple rows and add them""" """Format one or multiple rows and add them"""
stake_currency = config["stake_currency"] stake_currency = config["stake_currency"]
res = [ for r in results:
[ self.table.add_row(
*[
# "Best": # "Best":
( (
("*" if r["is_initial_point"] or r["is_random"] else "") ("*" if r["is_initial_point"] or r["is_random"] else "")
@@ -66,7 +67,7 @@ class HyperoptOutput:
# "Epoch": # "Epoch":
f"{r['current_epoch']}/{total_epochs}", f"{r['current_epoch']}/{total_epochs}",
# "Trades": # "Trades":
r["results_metrics"]["total_trades"], str(r["results_metrics"]["total_trades"]),
# "Win Draw Loss Win%": # "Win Draw Loss Win%":
generate_wins_draws_losses( generate_wins_draws_losses(
r["results_metrics"]["wins"], r["results_metrics"]["wins"],
@@ -76,6 +77,7 @@ class HyperoptOutput:
# "Avg profit": # "Avg profit":
f"{r['results_metrics']['profit_mean']:.2%}", f"{r['results_metrics']['profit_mean']:.2%}",
# "Profit": # "Profit":
Text(
"{} {}".format( "{} {}".format(
fmt_coin( fmt_coin(
r["results_metrics"]["profit_total_abs"], r["results_metrics"]["profit_total_abs"],
@@ -86,6 +88,8 @@ class HyperoptOutput:
) )
if r["results_metrics"]["profit_total_abs"] != 0.0 if r["results_metrics"]["profit_total_abs"] != 0.0
else "--", else "--",
style="green" if r["results_metrics"]["profit_total_abs"] > 0 else "red",
),
# "Avg duration": # "Avg duration":
r["results_metrics"]["holding_avg"], r["results_metrics"]["holding_avg"],
# "Objective": # "Objective":
@@ -101,7 +105,11 @@ class HyperoptOutput:
) )
if r["results_metrics"]["max_drawdown_account"] != 0.0 if r["results_metrics"]["max_drawdown_account"] != 0.0
else "--", else "--",
],
style=" ".join(
[
"bold " if r["is_best"] and highlight_best else "",
"italic " if r["is_initial_point"] else "",
] ]
for r in results ),
] )
self._add_rows(res)