Skip to content

Commit d262da9

Browse files
committed
Fix IBKR report managed symbols
1 parent a8f55f4 commit d262da9

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

main.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -297,12 +297,11 @@ def log_runtime_event(log_context, event, **fields):
297297

298298

299299
def build_execution_report(log_context):
300+
configured_managed_symbols = STRATEGY_RUNTIME_CONFIG.get("managed_symbols")
301+
fallback_managed_symbols = tuple(dict.fromkeys([*RANKING_POOL, SAFE_HAVEN])) if RANKING_POOL else (SAFE_HAVEN,)
300302
managed_symbols = tuple(
301303
str(symbol)
302-
for symbol in (
303-
STRATEGY_RUNTIME_CONFIG.get("managed_symbols")
304-
or tuple(dict.fromkeys([*RANKING_POOL, SAFE_HAVEN])) if RANKING_POOL else (SAFE_HAVEN,)
305-
)
304+
for symbol in (configured_managed_symbols or fallback_managed_symbols)
306305
if str(symbol or "").strip()
307306
)
308307
return build_runtime_report_base(

tests/test_request_handling.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,14 @@ def test_handle_request_persists_machine_readable_report(strategy_module, monkey
8585
assert observed["report"]["summary"]["signal_source"] == strategy_module.STRATEGY_SIGNAL_SOURCE
8686

8787

88+
def test_execution_report_prefers_configured_managed_symbols_without_ranking_pool(strategy_module_factory):
89+
module = strategy_module_factory(STRATEGY_PROFILE="soxl_soxx_trend_income")
90+
report = module.build_execution_report(module.RUNTIME_LOG_CONTEXT.with_run("run-001"))
91+
92+
assert report["summary"]["managed_symbols"] == ["SOXL", "SOXX", "BOXX", "QQQI", "SPYI"]
93+
assert report["summary"]["safe_haven"] == "BIL"
94+
95+
8896
def test_handle_request_enriches_runtime_report_with_cycle_details(strategy_module, monkeypatch):
8997
observed = {}
9098

0 commit comments

Comments
 (0)