mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-11-29 08:33:07 +00:00
Add max trade duration to backtest results
This commit is contained in:
@@ -370,6 +370,7 @@ def text_table_add_metrics(strat_results: dict) -> None:
|
|||||||
f"{strat_results['winning_days']} / "
|
f"{strat_results['winning_days']} / "
|
||||||
f"{strat_results['draw_days']} / {strat_results['losing_days']}",
|
f"{strat_results['draw_days']} / {strat_results['losing_days']}",
|
||||||
),
|
),
|
||||||
|
("Max trade duration", f"{strat_results['holding_max']}"),
|
||||||
("Avg. Duration Winners", f"{strat_results['winner_holding_avg']}"),
|
("Avg. Duration Winners", f"{strat_results['winner_holding_avg']}"),
|
||||||
("Avg. Duration Loser", f"{strat_results['loser_holding_avg']}"),
|
("Avg. Duration Loser", f"{strat_results['loser_holding_avg']}"),
|
||||||
(
|
(
|
||||||
|
|||||||
@@ -344,6 +344,11 @@ def generate_trading_stats(results: DataFrame) -> dict[str, Any]:
|
|||||||
if not results.empty
|
if not results.empty
|
||||||
else timedelta()
|
else timedelta()
|
||||||
)
|
)
|
||||||
|
holding_max = (
|
||||||
|
timedelta(minutes=round(results["trade_duration"].max()))
|
||||||
|
if not results.empty
|
||||||
|
else timedelta()
|
||||||
|
)
|
||||||
winner_holding_avg = (
|
winner_holding_avg = (
|
||||||
timedelta(minutes=round(winning_trades["trade_duration"].mean()))
|
timedelta(minutes=round(winning_trades["trade_duration"].mean()))
|
||||||
if not winning_trades.empty
|
if not winning_trades.empty
|
||||||
@@ -363,6 +368,8 @@ def generate_trading_stats(results: DataFrame) -> dict[str, Any]:
|
|||||||
"winrate": len(winning_trades) / len(results) if len(results) else 0.0,
|
"winrate": len(winning_trades) / len(results) if len(results) else 0.0,
|
||||||
"holding_avg": holding_avg,
|
"holding_avg": holding_avg,
|
||||||
"holding_avg_s": holding_avg.total_seconds(),
|
"holding_avg_s": holding_avg.total_seconds(),
|
||||||
|
"holding_max": holding_max,
|
||||||
|
"holding_max_s": holding_max.total_seconds(),
|
||||||
"winner_holding_avg": winner_holding_avg,
|
"winner_holding_avg": winner_holding_avg,
|
||||||
"winner_holding_avg_s": winner_holding_avg.total_seconds(),
|
"winner_holding_avg_s": winner_holding_avg.total_seconds(),
|
||||||
"loser_holding_avg": loser_holding_avg,
|
"loser_holding_avg": loser_holding_avg,
|
||||||
|
|||||||
Reference in New Issue
Block a user