Skip to content

Commit 59b1460

Browse files
author
Andras Kovacs
committed
Adding drawdown information for hyperopt-list --export-csv command
1 parent 2a526a8 commit 59b1460

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

freqtrade/optimize/hyperopt_tools.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,8 @@ def export_csv_file(config: Config, results: list, csv_file: str) -> None:
388388
"results_metrics.holding_avg",
389389
"results_metrics.trade_count_long",
390390
"results_metrics.trade_count_short",
391+
"results_metrics.max_drawdown_abs",
392+
"results_metrics.max_drawdown_account",
391393
"loss",
392394
"is_initial_point",
393395
"is_best",
@@ -409,6 +411,8 @@ def export_csv_file(config: Config, results: list, csv_file: str) -> None:
409411
"Avg duration",
410412
"Trade count long",
411413
"Trade count short",
414+
"Max drawdown",
415+
"Max drawdown percent",
412416
"Objective",
413417
"is_initial_point",
414418
"is_best",
@@ -432,6 +436,9 @@ def export_csv_file(config: Config, results: list, csv_file: str) -> None:
432436
trials["Avg profit"] = trials["Avg profit"].apply(
433437
lambda x: f"{x * perc_multi:,.2f}%" if not isna(x) else ""
434438
)
439+
trials["Max drawdown percent"] = trials["Max drawdown percent"].apply(
440+
lambda x: f"{x * perc_multi:,.2f}%" if not isna(x) else ""
441+
)
435442
trials["Objective"] = trials["Objective"].apply(
436443
lambda x: f"{x:,.5f}" if x != 100000 else ""
437444
)

tests/commands/test_commands.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1532,8 +1532,10 @@ def fake_iterator(*args, **kwargs):
15321532
assert csv_file.is_file()
15331533
line = csv_file.read_text()
15341534
assert (
1535-
'Best,1,2,-1.25%,-1.2222,-0.00125625,,-2.51,"3,930.0 m",0.43662' in line
1536-
or "Best,1,2,-1.25%,-1.2222,-0.00125625,,-2.51,2 days 17:30:00,2,0,0.43662" in line
1535+
'Best,1,2,-1.25%,-1.2222,-0.00125625,,-2.51,"3,930.0 m",-0.00125625,23.00%,0.43662' in line
1536+
or "Best,1,2,-1.25%,-1.2222,-0.00125625,,-2.51,2 days 17:30:00,2,0,-0.00125625,23.00%,"
1537+
"0.43662"
1538+
in line
15371539
)
15381540
csv_file.unlink()
15391541

0 commit comments

Comments
 (0)