from __future__ import annotations import json import sys from pathlib import Path PACKAGE_PARENT = Path(__file__).resolve().parents[2] if str(PACKAGE_PARENT) not in sys.path: sys.path.insert(0, str(PACKAGE_PARENT)) from strategy32.live.runtime import BEST_CASH_OVERLAY, LIVE_STRATEGY_OVERRIDES from strategy32.research.soft_router import evaluate_cash_overlay_exact, load_component_bundle OUT_JSON = Path("/tmp/strategy32_live_combo_backtest.json") CACHE_PATH = "/tmp/strategy32_fixed66_bundle.pkl" def main() -> None: bundle, latest_bar = load_component_bundle(CACHE_PATH) payload = evaluate_cash_overlay_exact( bundle=bundle, latest_bar=latest_bar, candidate=BEST_CASH_OVERLAY, cache_path=CACHE_PATH, max_workers=6, core_config_overrides={ **LIVE_STRATEGY_OVERRIDES, "hard_filter_refresh_cadence": "1d", "hard_filter_min_history_bars": 120, "hard_filter_lookback_bars": 30, "hard_filter_min_avg_dollar_volume": 50_000_000.0, }, ) payload["backtest_basis"] = { "universe": "fixed66 cached bundle", "core_filter": "overheat_tolerant", "cash_overlay": payload["candidate"], "core_config_overrides": { **LIVE_STRATEGY_OVERRIDES, "hard_filter_refresh_cadence": "1d", "hard_filter_min_history_bars": 120, "hard_filter_lookback_bars": 30, "hard_filter_min_avg_dollar_volume": 50_000_000.0, }, "execution_refinement_note": "4h proxy in research bundle; live 1h refinement is not replayed here", } OUT_JSON.write_text(json.dumps(payload, indent=2), encoding="utf-8") print(json.dumps(payload, indent=2)) print(f"[saved] {OUT_JSON}") if __name__ == "__main__": main()