Implement colors for hyperopt-output

This commit is contained in:
Matthias 2024-07-07 16:28:02 +02:00
parent 8f0ac0aaea
commit 4d6f399131

View File

@ -56,8 +56,9 @@ class HyperoptOutput:
"""Format one or multiple rows and add them"""
stake_currency = config["stake_currency"]
res = [
[
for r in results:
self.table.add_row(
*[
# "Best":
(
("*" if r["is_initial_point"] or r["is_random"] else "")
@ -66,7 +67,7 @@ class HyperoptOutput:
# "Epoch":
f"{r['current_epoch']}/{total_epochs}",
# "Trades":
r["results_metrics"]["total_trades"],
str(r["results_metrics"]["total_trades"]),
# "Win Draw Loss Win%":
generate_wins_draws_losses(
r["results_metrics"]["wins"],
@ -76,6 +77,7 @@ class HyperoptOutput:
# "Avg profit":
f"{r['results_metrics']['profit_mean']:.2%}",
# "Profit":
Text(
"{} {}".format(
fmt_coin(
r["results_metrics"]["profit_total_abs"],
@ -86,6 +88,8 @@ class HyperoptOutput:
)
if r["results_metrics"]["profit_total_abs"] != 0.0
else "--",
style="green" if r["results_metrics"]["profit_total_abs"] > 0 else "red",
),
# "Avg duration":
r["results_metrics"]["holding_avg"],
# "Objective":
@ -101,7 +105,11 @@ class HyperoptOutput:
)
if r["results_metrics"]["max_drawdown_account"] != 0.0
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)
),
)