@@ -57,6 +57,7 @@ ARGS_BACKTEST = [
|
|||||||
"backtest_breakdown",
|
"backtest_breakdown",
|
||||||
"backtest_cache",
|
"backtest_cache",
|
||||||
"freqai_backtest_live_models",
|
"freqai_backtest_live_models",
|
||||||
|
"backtest_notes",
|
||||||
]
|
]
|
||||||
|
|
||||||
ARGS_HYPEROPT = [
|
ARGS_HYPEROPT = [
|
||||||
|
|||||||
@@ -204,6 +204,11 @@ AVAILABLE_CLI_OPTIONS = {
|
|||||||
help="Export backtest results (default: trades).",
|
help="Export backtest results (default: trades).",
|
||||||
choices=constants.EXPORT_OPTIONS,
|
choices=constants.EXPORT_OPTIONS,
|
||||||
),
|
),
|
||||||
|
"backtest_notes": Arg(
|
||||||
|
"--notes",
|
||||||
|
help="Add notes to the backtest results.",
|
||||||
|
metavar="TEXT",
|
||||||
|
),
|
||||||
"exportfilename": Arg(
|
"exportfilename": Arg(
|
||||||
"--export-filename",
|
"--export-filename",
|
||||||
"--backtest-filename",
|
"--backtest-filename",
|
||||||
|
|||||||
@@ -310,6 +310,7 @@ class Configuration:
|
|||||||
("backtest_cache", "Parameter --cache={} detected ..."),
|
("backtest_cache", "Parameter --cache={} detected ..."),
|
||||||
("disableparamexport", "Parameter --disableparamexport detected: {} ..."),
|
("disableparamexport", "Parameter --disableparamexport detected: {} ..."),
|
||||||
("freqai_backtest_live_models", "Parameter --freqai-backtest-live-models detected ..."),
|
("freqai_backtest_live_models", "Parameter --freqai-backtest-live-models detected ..."),
|
||||||
|
("backtest_notes", "Parameter --notes detected: {} ..."),
|
||||||
]
|
]
|
||||||
self._args_to_config_loop(config, configurations)
|
self._args_to_config_loop(config, configurations)
|
||||||
|
|
||||||
|
|||||||
@@ -1822,7 +1822,11 @@ class Backtesting:
|
|||||||
# Update old results with new ones.
|
# Update old results with new ones.
|
||||||
if len(self.all_bt_content) > 0:
|
if len(self.all_bt_content) > 0:
|
||||||
results = generate_backtest_stats(
|
results = generate_backtest_stats(
|
||||||
data, self.all_bt_content, min_date=min_date, max_date=max_date
|
data,
|
||||||
|
self.all_bt_content,
|
||||||
|
min_date=min_date,
|
||||||
|
max_date=max_date,
|
||||||
|
notes=self.config.get("backtest_notes"),
|
||||||
)
|
)
|
||||||
if self.results:
|
if self.results:
|
||||||
self.results["metadata"].update(results["metadata"])
|
self.results["metadata"].update(results["metadata"])
|
||||||
|
|||||||
@@ -669,6 +669,7 @@ def generate_backtest_stats(
|
|||||||
all_results: dict[str, BacktestContentType],
|
all_results: dict[str, BacktestContentType],
|
||||||
min_date: datetime,
|
min_date: datetime,
|
||||||
max_date: datetime,
|
max_date: datetime,
|
||||||
|
notes: str | None = None,
|
||||||
) -> BacktestResultType:
|
) -> BacktestResultType:
|
||||||
"""
|
"""
|
||||||
:param btdata: Backtest data
|
:param btdata: Backtest data
|
||||||
@@ -694,6 +695,8 @@ def generate_backtest_stats(
|
|||||||
"backtest_start_ts": int(min_date.timestamp()),
|
"backtest_start_ts": int(min_date.timestamp()),
|
||||||
"backtest_end_ts": int(max_date.timestamp()),
|
"backtest_end_ts": int(max_date.timestamp()),
|
||||||
}
|
}
|
||||||
|
if notes:
|
||||||
|
metadata[strategy]["notes"] = notes
|
||||||
result["strategy"][strategy] = strat_stats
|
result["strategy"][strategy] = strat_stats
|
||||||
|
|
||||||
strategy_results = generate_strategy_comparison(bt_stats=result["strategy"])
|
strategy_results = generate_strategy_comparison(bt_stats=result["strategy"])
|
||||||
|
|||||||
Reference in New Issue
Block a user