diff --git a/main.py b/main.py index 4843ead..072cc54 100644 --- a/main.py +++ b/main.py @@ -297,12 +297,11 @@ def log_runtime_event(log_context, event, **fields): def build_execution_report(log_context): + configured_managed_symbols = STRATEGY_RUNTIME_CONFIG.get("managed_symbols") + fallback_managed_symbols = tuple(dict.fromkeys([*RANKING_POOL, SAFE_HAVEN])) if RANKING_POOL else (SAFE_HAVEN,) managed_symbols = tuple( str(symbol) - for symbol in ( - STRATEGY_RUNTIME_CONFIG.get("managed_symbols") - or tuple(dict.fromkeys([*RANKING_POOL, SAFE_HAVEN])) if RANKING_POOL else (SAFE_HAVEN,) - ) + for symbol in (configured_managed_symbols or fallback_managed_symbols) if str(symbol or "").strip() ) return build_runtime_report_base( diff --git a/tests/test_request_handling.py b/tests/test_request_handling.py index 43fe907..1faa8ac 100644 --- a/tests/test_request_handling.py +++ b/tests/test_request_handling.py @@ -85,6 +85,14 @@ def test_handle_request_persists_machine_readable_report(strategy_module, monkey assert observed["report"]["summary"]["signal_source"] == strategy_module.STRATEGY_SIGNAL_SOURCE +def test_execution_report_prefers_configured_managed_symbols_without_ranking_pool(strategy_module_factory): + module = strategy_module_factory(STRATEGY_PROFILE="soxl_soxx_trend_income") + report = module.build_execution_report(module.RUNTIME_LOG_CONTEXT.with_run("run-001")) + + assert report["summary"]["managed_symbols"] == ["SOXL", "SOXX", "BOXX", "QQQI", "SPYI"] + assert report["summary"]["safe_haven"] == "BIL" + + def test_handle_request_enriches_runtime_report_with_cycle_details(strategy_module, monkeypatch): observed = {}