Refine Runtime Port Adapters#17
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR tightens the shared runtime contract that the broker runtimes now rely on for orchestration decoupling.
The immediate issue was that platform repos were already moving toward
PortfolioPort/ExecutionPort/MarketDataPortbased wiring, but the shared translation helpers still dropped some account metadata on the floor. In particular,cash_by_currencyandsellable_quantitiescould be lost when converting between broker-native account state andPortfolioSnapshot, which makes cross-platform orchestration less predictable and forces platform code to keep broker-specific fallbacks around.Root cause
The shared runtime contract had the right high-level models, but the snapshot/account-state conversion path was still too lossy for the newer orchestration shape. At the same time, the platform-boundary guidance did not yet document the newer adapter/composer layering that the runtimes are now using.
What changed
quant_platform_kit.common.port_adaptersso runtimes can bind plain callables to shared ports with a thin local adapter layersellable_quantitieswhen building value-target portfolio inputs from aPortfolioSnapshotcash_by_currencyandsellable_quantitieswhen translating betweenPortfolioSnapshotandaccount_stateplatform_repo_boundaries.mdwith the local builder/composer guidance used by the platform reposValidation
python -m pytest tests/test_common_port_adapters.py tests/test_strategy_contracts.py