feat: store (sanitized) configuration

This commit is contained in:
Matthias
2025-03-23 15:44:55 +01:00
parent 23b10161d5
commit 9fa3a15e24
2 changed files with 7 additions and 0 deletions

View File

@@ -6,6 +6,7 @@ from zipfile import ZIP_DEFLATED, ZipFile
from pandas import DataFrame
from freqtrade.configuration import sanitize_config
from freqtrade.constants import LAST_BT_RESULT_FN
from freqtrade.enums.runmode import RunMode
from freqtrade.ft_types import BacktestResultType
@@ -85,6 +86,10 @@ def store_backtest_results(
dump_json_to_file(stats_buf, stats_copy)
zipf.writestr(json_filename.name, stats_buf.getvalue())
config_buf = StringIO()
dump_json_to_file(config_buf, sanitize_config(config["original_config"]))
zipf.writestr(f"{base_filename.stem}_config.json", config_buf.getvalue())
# Add market change data if present
if market_change_data is not None:
market_change_name = f"{base_filename.stem}_market_change.feather"

View File

@@ -303,6 +303,8 @@ def test_store_backtest_results_real(tmp_path):
with ZipFile(zip_file, "r") as zipf:
assert "backtest-result-2024_01_01_15_05_25.json" in zipf.namelist()
assert "backtest-result-2024_01_01_15_05_25_market_change.feather" in zipf.namelist()
assert "backtest-result-2024_01_01_15_05_25_config.json" in zipf.namelist()
assert (tmp_path / LAST_BT_RESULT_FN).is_file()
# Last file reference should be updated