Skip to content

Decouple IBKR Runtime Wiring - #35

Merged
Pigbibi merged 1 commit into
mainfrom
decouple-ibkr-runtime-wiring
Apr 21, 2026
Merged

Decouple IBKR Runtime Wiring#35
Pigbibi merged 1 commit into
mainfrom
decouple-ibkr-runtime-wiring

Conversation

@Pigbibi

@Pigbibi Pigbibi commented Apr 21, 2026

Copy link
Copy Markdown
Collaborator

Summary

This PR finishes the IBKR-side runtime decoupling work so the request entrypoint no longer owns broker wiring, strategy input assembly, notification transport, and report construction at the same time.

The runtime already had explicit IBKRRebalanceRuntime / IBKRRebalanceConfig bundles, but the top-level module was still carrying too many responsibilities. That made the request path hard to reason about, and every new feature or edge case risked pushing more orchestration back into main.py.

Root cause

The shared runtime shape had improved incrementally, but the IBKR repo still lacked the final local builder/composer layers that separate broker adapters, strategy adapters, notification publishing, and runtime reporting. As a result, main.py still mixed strategy, broker, transport, and HTTP concerns.

What changed

  • extracted IBKR broker-side wiring into local runtime broker adapters, including connection retry handling, portfolio snapshot loading, execution helpers, and paper-liquidation support
  • extracted strategy evaluation helpers into a dedicated runtime strategy adapter builder
  • extracted notification publishing and runtime report/log construction into local adapter builders
  • added a thin runtime composer that assembles those layers into IBKRRebalanceRuntime and IBKRRebalanceConfig
  • kept top-level helper functions in main.py as thin delegators so the existing request/runtime tests can still patch them without reintroducing orchestration into the entrypoint
  • added explicit composer coverage and kept the request/event-loop/strategy/rebalance tests on the new shape

Validation

  • ./.venv/bin/ruff check main.py application/runtime_notification_adapters.py application/runtime_reporting_adapters.py application/runtime_strategy_adapters.py application/runtime_broker_adapters.py application/runtime_composer.py tests/test_runtime_composer.py tests/test_event_loop.py tests/test_strategy_runtime.py tests/test_snapshot_strategy_runtime.py tests/test_request_handling.py tests/test_rebalance_service.py
  • ./.venv/bin/python -m pytest tests/test_runtime_composer.py tests/test_event_loop.py tests/test_strategy_runtime.py tests/test_snapshot_strategy_runtime.py tests/test_request_handling.py tests/test_rebalance_service.py

@Pigbibi
Pigbibi marked this pull request as ready for review April 21, 2026 10:23
@Pigbibi
Pigbibi merged commit f9252c1 into main Apr 21, 2026
1 of 2 checks passed
@Pigbibi
Pigbibi deleted the decouple-ibkr-runtime-wiring branch April 21, 2026 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant