fix(strategy): 实例做实审计补漏6项——①回测表单提交透传instance_id(CTA/组合两页原只预填不传,四格回写链路断头;组合页补档案预填max_pool/benchmark/pool)②模拟盘/实盘列表支持?instance=N按档案过滤(策略库行加模拟历史/实盘历史按钮,过滤中提示条可退出)③live创建补D1快照(setting用档案参数,API直调不绕过)④实盘账户也标参数漂移角标(D2只亮不同步;account_params_drifted兼容live setting字段)⑤paper页PORTFOLIO_LABELS换STRATEGY_LABELS共享⑥同步生效时机实证标注(实走每日结算重读DB次晚生效;影子进程常驻内存需重启,实证live_step/runner.py均从DB读);921绿+build绿 [vps]
CI/CD / test (push) Successful in 14s
CI/CD / nas-deploy (push) Successful in 45s
CI/CD / nas-verify (push) Successful in 10s

This commit is contained in:
2026-08-15 22:54:02 +08:00
parent 256820d36f
commit 2580b5c080
12 changed files with 79 additions and 18 deletions
+14 -4
View File
@@ -137,14 +137,24 @@ def get_instance_params_snapshot(inst_id: int) -> dict | None:
def account_params_drifted(snapshot_params: dict, account: dict) -> bool:
"""参数漂移检测(D2):账户 strategies 参数 vs 档案当前参数。
"""参数漂移检测(D2):账户参数 vs 档案当前参数。
account 为 paper_accounts 行(strategies 是 JSON 字符串或已解析 list)。
只比对参数键值(标的/周期改了也算漂移——都影响行为)。
account 兼容两种行:
- paper_accounts 行(strategies=[{params}]JSON 字符串或已解析)
- live_accounts 行(setting={params}JSON 字符串或已解析 dict
只比对参数键值。
"""
import json as _json
raw = account.get("strategies")
if isinstance(raw, str):
if raw is None and "setting" in account:
s = account["setting"]
if isinstance(s, str):
try:
s = _json.loads(s)
except (ValueError, TypeError):
return False
strats = [{"params": s}] if isinstance(s, dict) else []
elif isinstance(raw, str):
try:
strats = _json.loads(raw)
except (ValueError, TypeError):