Shared broker adapters, domain models, execution ports, and notification utilities for QuantStrategyLab strategies.
This repository is the shared platform layer for QuantStrategyLab strategy services.
It is intended to contain:
- common domain models
- narrow ports for market data, portfolio snapshots, execution, notifications, and state
- broker-specific adapters
- small reusable notification utilities
It is not intended to contain:
- strategy rules
- target allocation logic
- Cloud Run entrypoints
- scheduler or workflow orchestration specific to one strategy
The current mainline split is:
- platform repositories assemble
StrategyContext - platform repositories load a strategy entrypoint through
load_strategy_entrypoint(...) - strategy repositories return a unified
StrategyDecision - platform-local decision mappers turn that decision into broker orders, notifications, and runtime state updates
Strategy repositories should expose manifest + evaluate(ctx) and keep any migration-window runtime metadata behind StrategyRuntimeAdapter. Broker-specific order sequencing and UI layout should stay out of strategy outputs.
Migration details and follow-up guidance live in docs/strategy_contract_migration.md.
For the stricter end-state rules for new US equity strategies, see:
docs/us_equity_cross_platform_strategy_spec.mddocs/us_equity_cross_platform_strategy_spec.zh-CN.mddocs/us_equity_execution_translation_spec.mddocs/us_equity_execution_translation_spec.zh-CN.mddocs/us_equity_release_cutover_plan.mddocs/us_equity_release_cutover_plan.zh-CN.mddocs/us_equity_live_switch_runbook.mddocs/us_equity_live_switch_runbook.zh-CN.md
src/quant_platform_kit/
common/
models.py
ports.py
strategies.py
ibkr/
connection.py
market_data.py
portfolio.py
execution.py
binance/
client.py
account.py
market_data.py
execution.py
schwab/
auth.py
market_data.py
portfolio.py
execution.py
longbridge/
auth.py
market_data.py
portfolio.py
execution.py
notifications/
telegram.py
tests/
Run tests with:
PYTHONPATH=src python3 -m unittest discover -s testsQuantPlatformKit is a shared dependency, not a runtime service. Strategy repos should pin a fixed Git tag such as:
quant-platform-kit @ git+https://github.com/QuantStrategyLab/QuantPlatformKit.git@v0.7.1
Cloud Run and self-hosted runner deployments should continue to deploy the strategy repositories only. See docs/deployment_model.md for:
- service naming suggestions
- fixed-tag dependency rules
- Google Cloud trigger rebind steps after repo rename
- HK / SG multi-service guidance for
LongBridgePlatform - US equity cross-platform strategy contract rules
QuantPlatformKit 是 QuantStrategyLab 的共享平台层仓库。
它负责放这些内容:
- 统一领域模型
- 市场数据、持仓、执行、通知相关的公共接口
- IBKR / Schwab / LongBridge / Binance 的平台适配层
- 少量可复用的通知和运行时工具
它不负责放这些内容:
- 具体策略规则
- 目标仓位和调仓计算
- Cloud Run 或 VPS 入口
- 某一个平台仓库自己的调度和部署编排
这个仓库是各平台仓库共享的公共依赖。
当前主线边界已经固定为:
- 平台仓库负责组装
StrategyContext - 平台仓库通过
load_strategy_entrypoint(...)加载策略入口 - 策略仓库只返回统一的
StrategyDecision - 平台自己的 decision mapper 再把决策映射成券商订单、通知和运行时状态更新
策略仓库应该暴露 manifest + evaluate(ctx);如果迁移窗口里还需要少量运行时元数据,就放在 StrategyRuntimeAdapter 里,不要把券商专属下单顺序或展示布局塞回策略输出。
迁移说明和后续约束见 docs/strategy_contract_migration.md。
以后新增美股策略要遵守的更严格跨平台规范见:
docs/us_equity_cross_platform_strategy_spec.mddocs/us_equity_cross_platform_strategy_spec.zh-CN.mddocs/us_equity_live_switch_runbook.mddocs/us_equity_live_switch_runbook.zh-CN.md
src/quant_platform_kit/
common/
models.py
ports.py
strategies.py
ibkr/
connection.py
market_data.py
portfolio.py
execution.py
binance/
client.py
account.py
market_data.py
execution.py
schwab/
auth.py
market_data.py
portfolio.py
execution.py
longbridge/
auth.py
market_data.py
portfolio.py
execution.py
notifications/
telegram.py
tests/
运行测试:
PYTHONPATH=src python3 -m unittest discover -s testsQuantPlatformKit 只作为共享依赖,不单独部署。策略仓库应该固定依赖某个 Git tag,例如:
quant-platform-kit @ git+https://github.com/QuantStrategyLab/QuantPlatformKit.git@v0.7.1
部署说明见: