模块知识库/Vibe-Trading 量化交易智能体平台/Vibe-Trading Agent 核心运行时/交易连接器聚合层(Broker Connectors)/编码规范
- 每个 broker 子包遵循统一文件布局:
__init__.py 暴露 *_PROFILES、classification.py 声明 instrument/asset 分类、profiles.py 定义内置 profile 元数据、sdk.py 实现标准读写接口。
- Connector 配置采用 frozen dataclass +
from_mapping/with_overrides 模式(如 AlpacaConfig、IBKRLocalConfig),CLI/tool 覆盖值仅允许白名单字段生效。
- 所有外部 SDK 调用使用 try/except 包裹并以
{"status": "ok", ...} 或 {"status": "error", "error": ...} 字典返回,失败不向上传播异常(fail-closed)。
- 服务层对 live 写操作统一经
_route_sdk_write 或 execute_live_order 进入 mandate 门控与审计,paper 环境直接执行而不经过 gate。
- 读取操作返回值由
_with_profile 统一追加 profile_id/connector/environment/transport 元信息,保证上层无需感知具体 connector。
- 可选依赖(
alpaca-py、ib_async)通过模块级 _require_* 函数延迟 import,并提供 *_available() 探测函数,未安装时降级为健康检查报错而非启动失败。