feat(live): B3预算硬限制+GET /live/budget-info——实例预算制闸门(spec§B3)——①_budget_state:剩余=QMT账户现金−Σ同账户其他实盘实例预算(不分运行/停止,停止实例持仓仍占资金);快照缺失/过期(>10min)→fresh=False+remaining=None,fail-closed不猜数②create_live落库前_enforce_budget:超限400报文带现金/已分配/剩余三数;快照不可用400(重建期QMT关闭时创建被正确拒绝)③update_live补initial_capital可编辑+校验(仅预算或账号变更触发,改名不触发;exclude自身旧值防重复计入Σ)④GET /live/budget-info(必须注册在/live/{aid}前,FastAPI路径匹配不按类型分流否则422)→{account_cash,allocated,remaining,fresh,snapshot_at}供前端默认值+占用率条⑤存量不追溯(仅新建/修改走校验);+14预算测试,旧测试fixture补快照播种(test_portfolio_live/test_instance_binding,B3后create新契约);api+data_platform 273绿 [vps]

This commit is contained in:
2026-08-19 22:21:10 +08:00
parent e68c497f40
commit f9b6d77ebd
4 changed files with 270 additions and 0 deletions
+5
View File
@@ -21,6 +21,11 @@ def _setup(tmp_path, monkeypatch):
app = create_app(db_path=pdb)
set_paper_db(pdb)
set_live_db(ldb)
# B3 起 live/create 需新鲜账户快照,测试给用到的账号播种一份
from sanguo_live import persistence as _lp
for _acc in ("8886000519", "123"):
_lp.upsert_account_snapshot(ldb, _acc, cash=1e9, market_value=0,
total=1e9, positions=[])
return TestClient(app), create_token("admin")