feat(trader): live bridge token 改从 config 读取,免容器重建

容器 docker run(非 compose)注入 BRIDGE_TOKEN env 需重建容器,风险大。改为 live_cfg.bridge_token 优先、fallback BRIDGE_TOKEN env。run_live_step 每次 load_config,改 config 免重启即生效。

- _shadow_trades_to_bridge + reconcile_from_bridge 两处 token 读取
- config: live.bridge_token 占位空值(真实值填 NAS gitignored config,不入库)
- tests: +6 测试(config优先/env fallback/都无跳过),191 passed
This commit is contained in:
2026-07-13 19:30:58 +08:00
parent c041227139
commit 0761342baf
4 changed files with 102 additions and 5 deletions
+4 -4
View File
@@ -187,9 +187,9 @@ def _shadow_trades_to_bridge(db_path: str, account_id: int, today: str, cfg) ->
live_cfg = getattr(cfg, "live", None) or {}
if not live_cfg.get("enabled"):
return
token = os.environ.get("BRIDGE_TOKEN")
token = live_cfg.get("bridge_token") or os.environ.get("BRIDGE_TOKEN")
if not token:
logger.warning("live_step %s: 影子下单启用但 BRIDGE_TOKEN 未设,跳过", account_id)
logger.warning("live_step %s: 影子下单启用但 bridge_tokenconfig 或 BRIDGE_TOKEN env未设,跳过", account_id)
return
url = live_cfg.get("bridge_url")
if not url:
@@ -248,9 +248,9 @@ def reconcile_from_bridge(db_path: str, account_id: int, today: str,
return
if not live_cfg.get("mode_b"):
return
token = os.environ.get("BRIDGE_TOKEN")
token = live_cfg.get("bridge_token") or os.environ.get("BRIDGE_TOKEN")
if not token:
logger.warning("reconcile %s: mode_b 启用但 BRIDGE_TOKEN 未设,跳过", account_id)
logger.warning("reconcile %s: mode_b 启用但 bridge_tokenconfig 或 BRIDGE_TOKEN env未设,跳过", account_id)
return
url = live_cfg.get("bridge_url")
if not url: