Skip to content

Commit 215b648

Browse files
authored
Merge pull request freqtrade#11141 from andrasmining/develop
Adding drawdown information for hyperopt-list --export-csv command & small fix stake currency source
2 parents 93af2b7 + b820810 commit 215b648

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

freqtrade/optimize/hyperopt_tools.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,6 @@ def export_csv_file(config: Config, results: list, csv_file: str) -> None:
374374

375375
trials = json_normalize(results, max_level=1)
376376
trials["Best"] = ""
377-
trials["Stake currency"] = config["stake_currency"]
378377

379378
base_metrics = [
380379
"Best",
@@ -383,11 +382,13 @@ def export_csv_file(config: Config, results: list, csv_file: str) -> None:
383382
"results_metrics.profit_mean",
384383
"results_metrics.profit_median",
385384
"results_metrics.profit_total",
386-
"Stake currency",
385+
"results_metrics.stake_currency",
387386
"results_metrics.profit_total_abs",
388387
"results_metrics.holding_avg",
389388
"results_metrics.trade_count_long",
390389
"results_metrics.trade_count_short",
390+
"results_metrics.max_drawdown_abs",
391+
"results_metrics.max_drawdown_account",
391392
"loss",
392393
"is_initial_point",
393394
"is_best",
@@ -409,6 +410,8 @@ def export_csv_file(config: Config, results: list, csv_file: str) -> None:
409410
"Avg duration",
410411
"Trade count long",
411412
"Trade count short",
413+
"Max drawdown",
414+
"Max drawdown percent",
412415
"Objective",
413416
"is_initial_point",
414417
"is_best",
@@ -432,6 +435,9 @@ def export_csv_file(config: Config, results: list, csv_file: str) -> None:
432435
trials["Avg profit"] = trials["Avg profit"].apply(
433436
lambda x: f"{x * perc_multi:,.2f}%" if not isna(x) else ""
434437
)
438+
trials["Max drawdown percent"] = trials["Max drawdown percent"].apply(
439+
lambda x: f"{x * perc_multi:,.2f}%" if not isna(x) else ""
440+
)
435441
trials["Objective"] = trials["Objective"].apply(
436442
lambda x: f"{x:,.5f}" if x != 100000 else ""
437443
)

tests/commands/test_commands.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1532,8 +1532,11 @@ 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,BTC,-2.51,"3,930.0 m",-0.00125625,23.00%,0.43662'
1536+
in line
1537+
or "Best,1,2,-1.25%,-1.2222,-0.00125625,BTC,-2.51,2 days 17:30:00,2,0,-0.00125625,23.00%,"
1538+
"0.43662"
1539+
in line
15371540
)
15381541
csv_file.unlink()
15391542

0 commit comments

Comments
 (0)