@@ -47,10 +47,9 @@ def _result_payload(item: Any) -> dict[str, Any]:
4747 }
4848
4949
50- def _baseline_param_set_id (profile : str , params : dict [str , Any ], * , provenance : str | None = None ) -> str :
50+ def _baseline_param_set_id (profile : str , params : dict [str , Any ]) -> str :
5151 fingerprint = hashlib .sha256 (json .dumps (params , sort_keys = True , default = str ).encode ("utf-8" )).hexdigest ()[:12 ]
52- suffix = hashlib .sha256 (str (provenance or "unknown" ).encode ("utf-8" )).hexdigest ()[:8 ]
53- return f"{ profile } _baseline_{ fingerprint } _{ suffix } "
52+ return f"{ profile } _baseline_{ fingerprint } "
5453
5554
5655def _build_runner (* , profile : str , synthetic_days : int , panel : Any = None , market_history : Any = None ):
@@ -78,24 +77,37 @@ def run_walk_forward(
7877 raise ValueError (f"unsupported profile={ profile !r} ; supported={ sorted (SUPPORTED_PROFILES )} " )
7978
8079 params = dict (PROFILE_DEFAULTS .get (profile , {"min_history_days" : DEFAULT_MIN_HISTORY_DAYS }))
80+ store = PerformanceStore (local_root = store_root or Path ("/tmp/crypto_wf_store" ))
81+ orchestrator = BacktestOrchestrator (store = store )
82+
83+ baseline_params = copy .deepcopy (params )
84+ baseline_store_params = copy .deepcopy (baseline_params )
8185 baseline_runner = _build_runner (
8286 profile = profile ,
8387 panel = panel ,
8488 market_history = market_history ,
8589 synthetic_days = synthetic_days ,
8690 )
91+ baseline_raw = baseline_runner .run (
92+ profile ,
93+ baseline_params ,
94+ start_date = None ,
95+ end_date = None ,
96+ )
97+ baseline = orchestrator .persist_result (
98+ baseline_raw ,
99+ strategy_profile = profile ,
100+ domain = "crypto" ,
101+ params = baseline_store_params ,
102+ param_set_id = _baseline_param_set_id (profile , baseline_store_params ),
103+ )
87104 runner = _build_runner (
88105 profile = profile ,
89- panel = copy . deepcopy ( panel ) ,
90- market_history = copy . deepcopy ( market_history ) ,
106+ panel = panel ,
107+ market_history = market_history ,
91108 synthetic_days = synthetic_days ,
92109 )
93- store = PerformanceStore (local_root = store_root or Path ("/tmp/crypto_wf_store" ))
94- orchestrator = BacktestOrchestrator (store = store )
95110 orchestrator .register_runner ("crypto" , runner )
96-
97- baseline_params = copy .deepcopy (params )
98- baseline_raw = baseline_runner .run (profile , baseline_params )
99111 wf_params = copy .deepcopy (params )
100112 wf_results = orchestrator .walk_forward (
101113 profile ,
@@ -104,13 +116,6 @@ def run_walk_forward(
104116 windows = windows ,
105117 param_set_id = f"{ profile } _wf" ,
106118 )
107- baseline = orchestrator .persist_result (
108- baseline_raw ,
109- strategy_profile = profile ,
110- domain = "crypto" ,
111- params = baseline_params ,
112- param_set_id = _baseline_param_set_id (profile , baseline_params , provenance = getattr (baseline_raw , "run_id" , None ) or getattr (baseline_raw , "computed_at" , None )),
113- )
114119 return {
115120 "strategy_profile" : profile ,
116121 "domain" : "crypto" ,
0 commit comments