Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
8 changes: 8 additions & 0 deletions tests/test_request_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}

Expand Down