基本面
@@ -4126,8 +4132,9 @@ createApp({
if (s.buy_paused) return { text: kind + '只卖不买',
why: '决策系统提示' + (s.buy_paused.reason || '资金异动') + ',方案的买入腿已停;卖出与把当天做T买的那部分卖回去不受影响。' + st + '。' + tail };
return { text: kind + '运行中 · ' + st.split(' · ')[0],
- why: kind + '方案运行中:' + (_STRAT_HOW[s.type] || '') + ';' + st + '。方案票不走常规的补足、加仓、补仓与保垫减仓,SAR 止损由方案层管。'
- + (tail || '设了目标价才会到价清仓。') };
+ why: kind + '方案运行中:' + (_STRAT_HOW[s.type] || '') + ';' + st + '。方案票不走常规的补足、加仓、补仓与保垫减仓。'
+ + (s.type === 'GRID' ? '跌破网格下沿停止买入,不直接触发清仓;网格没有独立的 SAR 止损。' : s.type === 'TRAIL' ? '跟踪止盈按方案自身止盈与 SAR 条件处理。' : '')
+ + tail };
}
const d = dimsOf(r);
if (d.tech_phase === '转空') return { text: '离场纪律', why: '技术面刚转空,按纪律减持或清仓,自动还是人工由转空离场档位决定。' + tail };
@@ -4694,6 +4701,12 @@ createApp({
const csSrcLabel = { intraday: '决策与择时层', alerts: '盘中告警', sell_actions: '风控卖出',
metrics: '资金异动', mr: '实况评分' };
function csHeld(code) { return positions.value.some(p => code6(p.ts_code) === code6(code)); }
+ const csPosition = computed(() => positions.value.find(p => code6(p.ts_code) === code6(csCode.value)) || null);
+ const csGridExitNote = computed(() => {
+ const s = csPosition.value && stratOf(csPosition.value.ts_code);
+ return s && s.type === 'GRID' && csPosition.value.exit_detail?.status === '只卖不买'
+ ? '跌破网格下沿只停止买入,存量网格仓仍按原卖出条件处理;网格没有独立的 SAR 止损。' : '';
+ });
function csInPlan(code) { return planCodeSet.value.has(code6(code)); }
// 抽屉三段重构 (2026-09-14 §4.4): 今日信号段与系统动作段的几个取数, 抽成计算属性让模板干净。
const csSnapMetrics = computed(() => (csData.value && csData.value.snapshot && csData.value.snapshot.metrics) || []);
@@ -4723,16 +4736,14 @@ createApp({
return r;
}
const csVerdict = computed(() => {
- const f = techFeed.value; if (!f) return null;
+ const f = techFeed.value;
+ if (csPosition.value) {
+ const step = nextStepOf(csPosition.value);
+ return { cls: csPosition.value.exit_status_text ? 'queue' : 'wait', label: step.text, text: step.why, votes: f ? csVoteLine(f) : '' };
+ }
+ if (!f) return null;
const con = f.consensus || {}, tech = f.tech || {}, fund = f.fund || {};
const votes = csVoteLine(f);
- if (csHeld(csCode.value)) {
- if (tech.phase === '转空') return { cls: 'deny', label: '离场纪律', text: '技术面刚转空,按纪律减持或清仓', votes };
- if (con.direction === '看空') return { cls: 'deny', label: '增持暂停', text: '多数意见看空,只减不加', votes };
- if (tech.stance === '看空') return { cls: 'queue', label: '增持受限', text: '技术面偏空,暂停回踩补足与盈利加仓,减持照常', votes };
- if (fund.stance === '看空') return { cls: 'queue', label: '补仓受限', text: '基本面偏弱,暂停补仓', votes };
- return { cls: 'done', label: '持有', text: '意见未偏空,按纪律可增持', votes };
- }
const route = con.route;
if (!route) return { cls: 'wait', label: '暂无判断', text: '意见不全,等数据到齐', votes };
if (route === '放行') return { cls: 'done', label: '符合建仓条件', text: con.strength === '强' ? '三路意见一致看多,仍需通过建仓及执行检查' : '多数意见看多,仍需通过建仓及执行检查', votes };
@@ -5863,7 +5874,7 @@ createApp({
showOpLog, showSettings, watchCandidates, scanNotes, marketOpen, marketState, lastRefresh, autoRefresh,
upstream, showUpstream, usrc, loadUpstream, srcFail,
csOpen, csCode, csLoading, csErr, csData, csFromSnap, csTimeline, csSrcFails, csWatchRow, csWatchReports, refreshCodeResearch,
- csTruncated, csSrcLabel, csLedger, csLedgerErr, csHeld, csInPlan,
+ csTruncated, csSrcLabel, csLedger, csLedgerErr, csHeld, csInPlan, csPosition, csGridExitNote,
csSnapMetrics, csSnapMr, csSignalCount, csDisp, csLoadResearch, csLoadLedger,
csDetail, csToggle, csVerdict, csFundRow, csTechRow, csTimingRow, csPlainReason, csYmd,
openCodeSignals, closeCodeSignals, csLoadFull,
diff --git a/docs/退出等待展示与失效比较准备_2026-11-16.md b/docs/退出等待展示与失效比较准备_2026-11-16.md
new file mode 100644
index 0000000..c5689c2
--- /dev/null
+++ b/docs/退出等待展示与失效比较准备_2026-11-16.md
@@ -0,0 +1,37 @@
+# 退出等待展示与失效比较准备
+
+本批继续整改规格中的退出说明与离线比较准备。既定建仓、二次独立退出、人工止损、评级下调、网格下沿只停买等交易规则保持。只有web读取和展示路径变化,worker与WS无须重建。
+
+## 展示约定
+
+持仓列表与个股详情共用同一个“状态与下一步”解释。已有退出状态时先展示“只卖不买”“等待清仓”“清仓中”等实际阶段,不能被一般技术意见改写为“可增持”。详情在原系统判断区列出首次信号时间及原文、当前有效择时证据、下一步条件。首次信号时间是证据观察时间,不冒充实际停买落表时间;历史原文保持。
+
+当前择时从本地已保存结果读取并经过原有效期契约。未知、中性、多空分歧与无有效结论分别表达;新看空是否独立调用既有去重函数,不自建投票规则,不推进状态。刚收到新的独立看空但尚未处理时明确写“等待退出纪律处理”,不显示为已经清仓。人工止损与已有清仓阶段不等待第二条模型信号。
+
+网格说明明确:跌破下沿停止买入,存量网格仓按原卖出条件处理;网格没有独立SAR止损。普通持仓原有止盈止损、目标价与用户命令继续有效。
+
+回放发现四方列表使用11月12日扫描映射显示看多,详情按11月13日有效日线显示中性。持仓页面现统一调用详情既有`read_states_for`批量读取入口并将同一结果交给综合分析;读取失败或过期显示无有效技术读数,不退回旧看多映射。此修改不重写历史审计或交易扫描映射。
+
+## 验收标准与开发机结果
+
+| 场景 | 验收结果 |
+| --- | --- |
+| 首次停买与详情一般看多意见同时存在 | 摘要与详情均只卖不买,不出现“按纪律可增持” |
+| 当前结论过期、全部未知、真实中性、部分覆盖、多空分歧 | 分别表达,不把缺失伪装中性 |
+| 相同信号重复读、只有一组新证据、两组新证据 | 前两者不显示二次确认;后者仅显示待既有状态机处理 |
+| 旧版首次信号、新版当前信号、历史文本 | 可展示并保留原始依据,历史不被当前覆盖 |
+| 当前择时读取失败、人工止损或退出处理中 | 读取失败保留停买;退出处理中不附加二次确认等待 |
+| 当前技术日线更新、过期或读取失败 | 列表与详情共享有效日线;失败不回退旧看多映射 |
+| 1440×1000桌面与390×844窄屏 | 真实持仓与研究接口只读响应在本机回放;详情可打开、可关闭,窄屏详情宽367像素,无内部横向溢出;控制台无页面警告或错误 |
+
+退出专项47例(新增8例),持仓分组与当前技术专项17例(新增3例),页面三道护栏通过。开发机Python3.12最终88组全量断网回归通过,日志`/private/tmp/pms-exit-display-final-tests.log`。最后一次仅收窄择时参数读取的异常边界,退出专项另复核;服务器候选镜像仍须对最终提交做全量断网回归。
+
+浏览器回放使用12:11:56真实持仓、策略、名称与研究响应,以及12:10:23保存的退出状态,经新展示函数投影。其余页面区域使用预览占位或空响应,全部写接口拒绝;这不是155真实登录或交易验收。
+
+## 离线准备
+
+[固定协议与覆盖审计](../research/exit_invalidation_20261116/README.md)已落盘。四方7条相关账本只有6个不同合成事件,其中1次SELL与5次WAIT,首次方向记录和采纳记录不能合算为两次清仓。旧缓存截止11月10日,尚缺8只完整轮次及当时执行约束;先复现基线,再做反事实收益比较,不根据四方一个案例上线百分比止损或等待天数。
+
+## 发布状态
+
+发布与服务器候选回归结果在完成后追加,当前不得将本机通过写成真机已生效。
diff --git a/research/exit_invalidation_20261116/PROTOCOL.md b/research/exit_invalidation_20261116/PROTOCOL.md
new file mode 100644
index 0000000..c7d06f7
--- /dev/null
+++ b/research/exit_invalidation_20261116/PROTOCOL.md
@@ -0,0 +1,42 @@
+# 持仓失效条件离线比较协议 v1
+
+固定时间:2026年11月16日12:19:45,北京时间。此协议先于本目录统计运行;已知杰普特与四方个案,不属于盲测或独立样本外研究。所有实验只读,不改变155运行规则。
+
+## 问题与基线
+
+比较“暂停新增后等待独立退出确认”与“持仓理由失效后有明确处理条件”,分别衡量退出及时性、误退与可执行性。基线沿用实际版本:首次有效清仓信号停买,第二次独立确认退出,正式评级下调、人工止损、目标价与用户命令按原规则优先。网格下沿当前只停买,不能在基线中偷偷改成止损。
+
+先核验2026年11月2日模拟仓重置后的全部沪深持仓轮次。首批覆盖核验限定复盘所列8只股票;本目录现有PMS状态快照仅覆盖4只当前持仓,不能冒充完整8只交易历史。11月11日新版多源择时启用前后的实际规则分别复现,旧模型广播不能反算为新规则当时已发布。更长周期仅在能够还原当时数据、版本和资格后另立协议扩展;不因一年分钟价格齐全就宣称有一年择时实发记录。
+
+## 对照方案
+
+| 方案 | 固定定义 | 可评价范围 |
+| --- | --- | --- |
+| A 既定规则 | 按实际版本、命令和真实证据身份复现 | 先复现已发生动作,再谈收益差异 |
+| B 价格失效 | 只使用建仓或策略批准时已保存的失效价、网格下沿;首个日收盘低于该界限后,下一交易日首个有效可执行报价仍低于原界限才触发反事实退出 | 研究性对照;当时未保存界限则缺失,不从后来低点反推 |
+| C 连续破位 | 与B相同,但要求连续两个交易日收盘低于同一个原界限,第三日按同一报价规则执行 | 固定敏感性对照,不从收益最高者选“最佳确认天数” |
+| D 等待复核 | 首次停买后满1、2、3个完整交易日仍未退出,各生成一次人工复核提示 | 只评价覆盖、等待与复核工作量;没有人工决定及执行规则,不计算该提示的交易收益 |
+
+B、C均为整轮退出的假设对照,不能上线。真实用户命令、T+1、在途撤单与数量归属仍优先;遇到用户明确禁止该动作时标记不可执行,不用假设覆盖命令。试探原预算与后续独立策略预算保持原分工,不将“试探”自动变成整轮禁买。
+
+## 数据与时序
+
+每轮至少包括:账本和轮次、原计划及历次批准版本、建仓与策略参数生效时间、各批成交与可卖数量、每条信号的观察时间/首次收到时间/有效期/证据身份、评级报告发布日期及接收时间、分钟或日线价格、涨跌停和停牌、用户命令生效与撤销时间。历史人工止损不存在时不补设。
+
+SQL在采集端逐表读取,服务层按原ID组合;沪深代码在入口过滤。数据库中的晚到回填价量可用于敏感性研究,但没有当时可得时间时不得作为实盘可执行证据。旧QRS数据日不符、同一证据重发、未知组与真实中性分别统计;禁止把缺失填零或从未来评级倒填持仓失效。
+
+收盘信号最早下一交易日执行。T+1、停牌、跌停无买盘或报价无效时延迟并记录;缺少盘口时仅作价格路径研究,不声明可成交。部分成交、最低申报、撤单确认与迟到成交继续归原策略。费用先复现账本零费用,再列单边5和10基点的统一摩擦压力;后者是研究假设,不能称实际佣金。没有可执行价的轮次不填收益。
+
+## 指标与验收
+
+1. 输出逐轮时间线、来源ID、版本和缺失原因;原始审计和当前显示分别保存。截断到任意历史日重跑,不得使用截断后的数据。
+2. A先与真实指令、成交数量及账本金额逐笔对齐。无法还原的轮次单列,不用事后价格“修正”基线。资金、数量和批次守恒必须通过。
+3. 比较从首次停买到可执行退出的交易日与交易分钟、期间最大不利价格变化、后续5/10交易日价格路径、费用后可执行收益、未成交比例与人工复核量。后续不足窗口标记右截尾,不填零。
+4. 按普通持仓/网格、旧版/新版信号、上涨/震荡/下跌阶段分别报告。市场阶段须在扩样协议中用此前数据固定划分,不能按实验收益挑区间。
+5. 不把同一股票多个参数当独立样本;小样本只报告案例和覆盖,不报告胜率显著性或推荐最优参数。收益比较必须同时给退出后反弹代价与未能执行的情况。
+
+## 开发顺序与交付门槛
+
+第一步运行本目录`audit_coverage.py`,只回答现有资料能否支撑后续比较。第二步按缺项采集8只完整历史轮次、当时参数及分钟执行约束,形成有哈希的输入清单。第三步实现A的逐笔复现和截断检查;A未通过不得发布B/C收益结论。第四步执行固定B/C/D并出分层报告。新增研究分支或参数范围须保留本协议,另写v2。
+
+当前交付是数据准备与开发验收口径,尚未达到退出阈值选择或生产变更的验收门槛。
diff --git a/research/exit_invalidation_20261116/README.md b/research/exit_invalidation_20261116/README.md
new file mode 100644
index 0000000..212d8fc
--- /dev/null
+++ b/research/exit_invalidation_20261116/README.md
@@ -0,0 +1,26 @@
+# 退出失效比较:数据准备
+
+本目录保存固定协议、只读快照、覆盖审计脚本与结果;尚未计算反事实收益或选择生产退出阈值。[协议](PROTOCOL.md)给出基线、三个对照方向、时序、费用假设与开发验收门槛。
+
+2026年11月16日12:10:23从155模拟PMS只读取得当前4只持仓的退出状态及11月11日16:17:11以来的相关账本。雷赛和宁德各承接1次旧版清仓信号,四方有1次新版合成看空信号,药明为正常观察。四方7条相关账本对应6个不同事件:1次SELL、5次WAIT;7551与7552是同一首次事件的方向记录与采纳记录。最新保存核验时间为11月16日11:30:06,午间读取时已经超过有效期,不能写成当前有效看空或中性。
+
+对既有归档缓存按复盘8只沪深股票、11月2日至13日筛选,实际仅覆盖至11月10日:
+
+| 缓存来源原名 | 记录数 | 有事件日期数 | 最晚日期 |
+| --- | ---: | ---: | --- |
+| mtf | 21 | 7 | 11月10日 |
+| qrs | 7 | 5 | 11月10日 |
+| distribution | 5 | 3 | 11月9日 |
+| bionic | 10 | 5 | 11月10日 |
+
+其中5条QRS引用的数据日期早于11月2日;这只是明显旧数据的下限检查,尚未逐条核对前一交易日。旧缓存不是新版合成择时逐时可用输入,零记录也不等于当时没有信号或系统停摆。这里不把旧QRS重算值冒充历史发布值。
+
+下一步按协议第二步补8只完整历史轮次、原计划与策略参数版本、历史命令及分钟执行约束,然后先复现实际基线。已有一年分钟归档不能补出当时发布时间、证据身份和模型输入;缺这些字段的轮次只能做价格路径研究,不能称可执行收益回测。
+
+开发机Python3.12通过项目断网护栏执行:
+
+```bash
+python scripts/unit_test_guard.py research/exit_invalidation_20261116/audit_coverage.py
+```
+
+脚本读取本目录`holding_snapshot.json`及此前已归档的`signal_independence_20261111/data/normalized.csv.gz`,入口限定8只沪深代码,不访问真实服务。`coverage.json`记录输入和协议哈希、统计、重复账本ID及局限。没有修改交易参数、信号、委托或持仓。
diff --git a/research/exit_invalidation_20261116/audit_coverage.py b/research/exit_invalidation_20261116/audit_coverage.py
new file mode 100644
index 0000000..d81bed7
--- /dev/null
+++ b/research/exit_invalidation_20261116/audit_coverage.py
@@ -0,0 +1,63 @@
+"""只读既有沪深缓存,核验退出比较的数据边界;不回测收益、不联网。"""
+import csv
+import gzip
+import hashlib
+import json
+from collections import Counter
+from pathlib import Path
+
+ROOT = Path(__file__).resolve().parent
+CODES = {'688025.SH', '601126.SH', '002979.SZ', '603667.SH',
+ '603259.SH', '300124.SZ', '688100.SH', '300750.SZ'}
+assert all(c.endswith(('.SH', '.SZ')) for c in CODES)
+
+
+def main():
+ source = ROOT/'holding_snapshot.json'
+ old = ROOT.parent/'signal_independence_20261111/data/normalized.csv.gz'
+ snapshot = json.loads(source.read_text())
+ by_source = {}
+ with gzip.open(old, 'rt', encoding='utf-8') as stream:
+ for r in csv.DictReader(stream):
+ if r['code'] not in CODES or not '2026-11-02' <= r['day'] <= '2026-11-13':
+ continue
+ info = by_source.setdefault(r['source'], {'rows': 0, 'days': set(), 'codes': set(), 'old_qrs_evidence': 0})
+ info['rows'] += 1
+ info['days'].add(r['day']); info['codes'].add(r['code'])
+ # 仅统计明显早于重置日的数据;不以自然日差代替前一交易日核验。
+ if r['source'] == 'qrs' and r['evidence_date'] and r['evidence_date'] < '2026-11-02':
+ info['old_qrs_evidence'] += 1
+ for info in by_source.values():
+ info['days'] = sorted(info['days']); info['codes'] = sorted(info['codes'])
+ holdings = {}
+ for code, row in snapshot['stocks'].items():
+ assert code in CODES
+ state = row['risk_exit'] or {}
+ unique = {}
+ refs = {}
+ for record in row['ledger']:
+ hard = record['hard_numbers']
+ e = hard.get('timing_direction') or hard.get('event')
+ if not e or e.get('source') != 'timing_fusion':
+ continue
+ assert e['ts_code'] == code and len(e['key']) == 64
+ unique[e['key']] = e
+ refs.setdefault(e['key'], []).append(record['id'])
+ holdings[code] = {'phase': state.get('phase'), 'accepted_signals': len(state.get('events') or []),
+ 'first_source': (state.get('events') or [{}])[0].get('source'),
+ 'ledger_rows': len(row['ledger']), 'distinct_fusion_events': len(unique),
+ 'actions': dict(Counter(e['action'] for e in unique.values())),
+ 'same_event_ledger_rows': [ids for ids in refs.values() if len(ids)>1],
+ 'latest_saved_verified_at': (row.get('timing') or {}).get('verified_at')}
+ output = {'snapshot_at': snapshot['at'], 'scope': sorted(CODES),
+ 'inputs': {str(p.relative_to(ROOT.parent.parent)): hashlib.sha256(p.read_bytes()).hexdigest() for p in (source, old, ROOT/'PROTOCOL.md')},
+ 'archived_old_signal_coverage': by_source, 'current_holdings': holdings,
+ 'limitations': ['本次PMS账本查询从11月11日16:17:11起且只含4只当前持仓,不能代表完整8只轮次。',
+ '旧规范化缓存截止11月10日,不含新合成规则的完整历史输入。',
+ '未核齐原计划、全部历史命令、分钟可执行约束与首次可得时间,不具备反事实收益计算条件。']}
+ (ROOT/'coverage.json').write_text(json.dumps(output, ensure_ascii=False, indent=2)+'\n')
+ print(json.dumps(output, ensure_ascii=False, indent=2))
+
+
+if __name__ == '__main__':
+ main()
diff --git a/research/exit_invalidation_20261116/coverage.json b/research/exit_invalidation_20261116/coverage.json
new file mode 100644
index 0000000..e733d27
--- /dev/null
+++ b/research/exit_invalidation_20261116/coverage.json
@@ -0,0 +1,145 @@
+{
+ "snapshot_at": "2026-11-16T12:10:23.658202",
+ "scope": [
+ "002979.SZ",
+ "300124.SZ",
+ "300750.SZ",
+ "601126.SH",
+ "603259.SH",
+ "603667.SH",
+ "688025.SH",
+ "688100.SH"
+ ],
+ "inputs": {
+ "research/exit_invalidation_20261116/holding_snapshot.json": "0dad98ae1d434acc42363b4be11b308d6463d747adc44efc8e5b73c54dd5d25f",
+ "research/signal_independence_20261111/data/normalized.csv.gz": "d273edd669e3b6ad4f7d5349303ef98fa6a129b458a93d2cc0f9f4b7022e1d1a",
+ "research/exit_invalidation_20261116/PROTOCOL.md": "a1d4a844b401771a3c3fee94d0c9f8b816739cb2d244969edf61b53313121e55"
+ },
+ "archived_old_signal_coverage": {
+ "mtf": {
+ "rows": 21,
+ "days": [
+ "2026-11-02",
+ "2026-11-03",
+ "2026-11-04",
+ "2026-11-05",
+ "2026-11-06",
+ "2026-11-09",
+ "2026-11-10"
+ ],
+ "codes": [
+ "002979.SZ",
+ "300124.SZ",
+ "300750.SZ",
+ "601126.SH",
+ "603259.SH",
+ "603667.SH",
+ "688025.SH",
+ "688100.SH"
+ ],
+ "old_qrs_evidence": 0
+ },
+ "qrs": {
+ "rows": 7,
+ "days": [
+ "2026-11-04",
+ "2026-11-05",
+ "2026-11-06",
+ "2026-11-09",
+ "2026-11-10"
+ ],
+ "codes": [
+ "603259.SH",
+ "688025.SH"
+ ],
+ "old_qrs_evidence": 5
+ },
+ "distribution": {
+ "rows": 5,
+ "days": [
+ "2026-11-04",
+ "2026-11-06",
+ "2026-11-09"
+ ],
+ "codes": [
+ "603667.SH",
+ "688025.SH",
+ "688100.SH"
+ ],
+ "old_qrs_evidence": 0
+ },
+ "bionic": {
+ "rows": 10,
+ "days": [
+ "2026-11-04",
+ "2026-11-05",
+ "2026-11-06",
+ "2026-11-09",
+ "2026-11-10"
+ ],
+ "codes": [
+ "002979.SZ",
+ "300750.SZ",
+ "603667.SH",
+ "688025.SH",
+ "688100.SH"
+ ],
+ "old_qrs_evidence": 0
+ }
+ },
+ "current_holdings": {
+ "002979.SZ": {
+ "phase": "STOP_BUY",
+ "accepted_signals": 1,
+ "first_source": "intraday",
+ "ledger_rows": 0,
+ "distinct_fusion_events": 0,
+ "actions": {},
+ "same_event_ledger_rows": [],
+ "latest_saved_verified_at": null
+ },
+ "300750.SZ": {
+ "phase": "STOP_BUY",
+ "accepted_signals": 1,
+ "first_source": "intraday",
+ "ledger_rows": 0,
+ "distinct_fusion_events": 0,
+ "actions": {},
+ "same_event_ledger_rows": [],
+ "latest_saved_verified_at": null
+ },
+ "601126.SH": {
+ "phase": "STOP_BUY",
+ "accepted_signals": 1,
+ "first_source": "timing_fusion",
+ "ledger_rows": 7,
+ "distinct_fusion_events": 6,
+ "actions": {
+ "SELL": 1,
+ "WAIT": 5
+ },
+ "same_event_ledger_rows": [
+ [
+ 7551,
+ 7552
+ ]
+ ],
+ "latest_saved_verified_at": "2026-11-16T11:30:06.112487+08:00"
+ },
+ "603259.SH": {
+ "phase": "WATCH",
+ "accepted_signals": 0,
+ "first_source": null,
+ "ledger_rows": 0,
+ "distinct_fusion_events": 0,
+ "actions": {},
+ "same_event_ledger_rows": [],
+ "latest_saved_verified_at": null
+ }
+ },
+ "limitations": [
+ "本次PMS账本查询从11月11日16:17:11起且只含4只当前持仓,不能代表完整8只轮次。",
+ "旧规范化缓存截止11月10日,不含新合成规则的完整历史输入。",
+ "未核齐原计划、全部历史命令、分钟可执行约束与首次可得时间,不具备反事实收益计算条件。"
+ ]
+}
diff --git a/research/exit_invalidation_20261116/holding_snapshot.json b/research/exit_invalidation_20261116/holding_snapshot.json
new file mode 100644
index 0000000..cae39a3
--- /dev/null
+++ b/research/exit_invalidation_20261116/holding_snapshot.json
@@ -0,0 +1,646 @@
+{
+ "at": "2026-11-16T12:10:23.658202",
+ "stocks": {
+ "002979.SZ": {
+ "risk_exit": {
+ "book_id": "original",
+ "code": "002979.SZ",
+ "count": 1,
+ "events": [
+ {
+ "at": "2026-11-05T09:38:00+08:00",
+ "confidence": 0.95,
+ "content": "c2ce2d3356a931fedaa2f71a697b64fbb784ee378ea1aa4a67a2c81417f69573",
+ "key": "22b2592673f336bff46ddb92fad2047ad18d9ffa5c3817093a2c04fbcfad5b6d",
+ "legacy_proposal": "PRP_20261105_002979SZ_SIGSELL",
+ "msg_id": "legacy:PRP_20261105_002979SZ_SIGSELL",
+ "reason": "量比3.82倍放量但主力净流出10%、主散背离-20,RECHECK判定为诱多分布而非突破,兑现离场",
+ "source": "intraday",
+ "source_id": "PRP_20261105_002979SZ_SIGSELL"
+ }
+ ],
+ "exit_seq": 0,
+ "initialized_at": "2026-11-05T12:30:46.297993+08:00",
+ "lot_ids": [
+ "1450",
+ "1451"
+ ],
+ "opened_date": "2026-11-03",
+ "phase": "STOP_BUY",
+ "reason": "第一次清仓信号已确认,停止新增买入,等待第二次独立信号",
+ "review": {
+ "at": "2026-11-07T02:41:09.701344+08:00",
+ "grade": "好",
+ "ref": "fc1d7677b32b2c031616afcae1b726f019953f25c8f343358865933e7dba6081"
+ },
+ "round_id": "aba55771d5d2f4daaeec",
+ "stopped_parents": [
+ "INS_20261103_002979SZ_OPEN_001_134e680ae814",
+ "STR20261104094500_002979SZ_g"
+ ]
+ },
+ "timing": null,
+ "ledger": []
+ },
+ "300750.SZ": {
+ "risk_exit": {
+ "book_id": "original",
+ "code": "300750.SZ",
+ "count": 1,
+ "events": [
+ {
+ "at": "2026-11-09T10:30:28.262000+08:00",
+ "confidence": 0.95,
+ "content": "18b753a2e1a701268e470cb7a82c3558e6eff306455e85d38067d09d591de2fb",
+ "key": "da626c281f1deddaa9f1c5ce1fb98ca81f6aa090870eee655484a899b5ac0a9c",
+ "msg_id": "1794191161506-0",
+ "reason": "放量破249缺口下沿,岛形反转结构破坏,主力净流出印证,执行止损离场",
+ "source": "intraday",
+ "source_id": "20261109_103028_300750.SZ"
+ }
+ ],
+ "exit_seq": 0,
+ "initialized_at": "2026-11-09T09:58:03.529900+08:00",
+ "lot_ids": [
+ "1459"
+ ],
+ "opened_date": "2026-11-09",
+ "phase": "STOP_BUY",
+ "reason": "第一次清仓信号已确认,停止新增买入,等待第二次独立信号",
+ "review": {
+ "at": "2026-11-10T03:08:05.814280+08:00",
+ "grade": "好",
+ "ref": "3d3ae1d536521e82893ec1b5735e6d49cb865e83b86d023194b35f1d316c9132"
+ },
+ "round_id": "a313e69d301cdcd29f71",
+ "stopped_parents": [
+ "INS_20261109_300750SZ_OPEN_93201"
+ ]
+ },
+ "timing": null,
+ "ledger": []
+ },
+ "601126.SH": {
+ "risk_exit": {
+ "book_id": "original",
+ "code": "601126.SH",
+ "count": 1,
+ "events": [
+ {
+ "action": "SELL",
+ "at": "2026-11-12T13:56:48+08:00",
+ "coverage": 2,
+ "expires_at": "2026-11-12T13:59:05.546250+08:00",
+ "groups": {
+ "main_fund": {
+ "direction": 0,
+ "evidence": [],
+ "state": "UNKNOWN",
+ "weight": 0.3333333333333333
+ },
+ "qrs": {
+ "direction": -1,
+ "evidence": [
+ {
+ "at": "2026-11-12T09:30:00+08:00",
+ "direction": -1,
+ "expires_at": "2026-11-12T15:00:00+08:00",
+ "group": "qrs",
+ "identity": "372dc66d4823b83b47aecef68c7e62c1ba3a19025a7cbaff0a9bff35358dcedb",
+ "source": "daily_qrs_symmetric_down",
+ "ts_code": "601126.SH"
+ }
+ ],
+ "state": "VALID",
+ "weight": 0.3333333333333333
+ },
+ "v3f": {
+ "direction": -1,
+ "evidence": [
+ {
+ "at": "2026-11-12T13:56:48+08:00",
+ "direction": -1,
+ "expires_at": "2026-11-12T14:41:48+08:00",
+ "group": "v3f",
+ "identity": "9b4548fc81f478ec3d7fcc717a806254691eb03756577a0af7d5b0b3fe6c9211",
+ "source": "mtf_v3f",
+ "ts_code": "601126.SH"
+ }
+ ],
+ "state": "VALID",
+ "weight": 0.3333333333333333
+ }
+ },
+ "key": "e7f7eb097cb26ead20fdb6cf6674c4abd1a1ad6768fd8392f110c51aa6af2b8d",
+ "reason": "三组独立证据:同向看空",
+ "score": -0.666666667,
+ "source": "timing_fusion",
+ "ts_code": "601126.SH",
+ "verified_at": "2026-11-12T13:57:05.546250+08:00",
+ "version": "timing_fusion_v1"
+ }
+ ],
+ "exit_seq": 0,
+ "initialized_at": "2026-11-06T09:45:02.283085+08:00",
+ "lot_ids": [
+ "1456",
+ "1458",
+ "1460"
+ ],
+ "opened_date": "2026-11-06",
+ "phase": "STOP_BUY",
+ "reason": "第一次清仓信号已确认,停止新增买入,等待第二次独立信号",
+ "review": {
+ "at": "2026-11-02T12:15:00.791329+08:00",
+ "grade": "好",
+ "ref": "5caefe48f8776bc10d22c1e4802cbdbec3f49af24c14b17920e988c6490b3358"
+ },
+ "round_id": "c4d5ad09d8b4c8720940",
+ "stopped_parents": [
+ "INS_20261106_601126SH_OPEN_93200",
+ "STR20261109094705_601126SH_g",
+ "STR20261110094004_601126SH_g"
+ ]
+ },
+ "timing": {
+ "action": "WAIT",
+ "at": "2026-11-16T09:30:00+08:00",
+ "coverage": 1,
+ "expires_at": "2026-11-16T11:32:06.112487+08:00",
+ "groups": {
+ "main_fund": {
+ "direction": 0,
+ "evidence": [],
+ "state": "UNKNOWN",
+ "weight": 0.3333333333333333
+ },
+ "qrs": {
+ "direction": -1,
+ "evidence": [
+ {
+ "at": "2026-11-16T09:30:00+08:00",
+ "direction": -1,
+ "expires_at": "2026-11-16T15:00:00+08:00",
+ "group": "qrs",
+ "identity": "5ba6fa755e77cf4b0cde2111f68fcb1f7fd5c2818c15ab52ca06cb5d04d00080",
+ "source": "daily_qrs_symmetric_down",
+ "ts_code": "601126.SH"
+ }
+ ],
+ "state": "VALID",
+ "weight": 0.3333333333333333
+ },
+ "v3f": {
+ "direction": 0,
+ "evidence": [],
+ "state": "UNKNOWN",
+ "weight": 0.3333333333333333
+ }
+ },
+ "key": "63a2f3b523052fc404636ec7e886bd6a01234729a0466cf29c35f9c8c5b85031",
+ "reason": "三组独立证据:证据不足或方向冲突,等待",
+ "score": -0.333333333,
+ "source": "timing_fusion",
+ "ts_code": "601126.SH",
+ "verified_at": "2026-11-16T11:30:06.112487+08:00",
+ "version": "timing_fusion_v1"
+ },
+ "ledger": [
+ {
+ "id": 7551,
+ "ts_code": "601126.SH",
+ "decided_at": "2026-11-12 13:57:06",
+ "action": "SIGNAL",
+ "arbiter": "system",
+ "verdict": "NOTE",
+ "price_at": "0.000",
+ "reason": "三组独立证据:同向看空",
+ "ref_id": "e7f7eb097cb26ead20fdb6cf6674c4abd1a1ad6768fd8392f110c51aa6af2b8d",
+ "outcome_scored": 0,
+ "book_id": "original",
+ "hard_numbers": {
+ "timing_direction": {
+ "version": "timing_fusion_v1",
+ "ts_code": "601126.SH",
+ "source": "timing_fusion",
+ "key": "e7f7eb097cb26ead20fdb6cf6674c4abd1a1ad6768fd8392f110c51aa6af2b8d",
+ "action": "SELL",
+ "score": -0.666666667,
+ "coverage": 2,
+ "groups": {
+ "qrs": {
+ "weight": 0.3333333333333333,
+ "state": "VALID",
+ "direction": -1,
+ "evidence": [
+ {
+ "ts_code": "601126.SH",
+ "group": "qrs",
+ "direction": -1,
+ "at": "2026-11-12T09:30:00+08:00",
+ "expires_at": "2026-11-12T15:00:00+08:00",
+ "identity": "372dc66d4823b83b47aecef68c7e62c1ba3a19025a7cbaff0a9bff35358dcedb",
+ "source": "daily_qrs_symmetric_down"
+ }
+ ]
+ },
+ "main_fund": {
+ "weight": 0.3333333333333333,
+ "state": "UNKNOWN",
+ "direction": 0,
+ "evidence": []
+ },
+ "v3f": {
+ "weight": 0.3333333333333333,
+ "state": "VALID",
+ "direction": -1,
+ "evidence": [
+ {
+ "ts_code": "601126.SH",
+ "group": "v3f",
+ "direction": -1,
+ "at": "2026-11-12T13:56:48+08:00",
+ "expires_at": "2026-11-12T14:41:48+08:00",
+ "identity": "9b4548fc81f478ec3d7fcc717a806254691eb03756577a0af7d5b0b3fe6c9211",
+ "source": "mtf_v3f"
+ }
+ ]
+ }
+ },
+ "at": "2026-11-12T13:56:48+08:00",
+ "verified_at": "2026-11-12T13:57:05.546250+08:00",
+ "expires_at": "2026-11-12T13:59:05.546250+08:00",
+ "reason": "三组独立证据:同向看空"
+ }
+ }
+ },
+ {
+ "id": 7552,
+ "ts_code": "601126.SH",
+ "decided_at": "2026-11-12 13:57:06",
+ "action": "SIGNAL",
+ "arbiter": "system",
+ "verdict": "PASS",
+ "price_at": "0.000",
+ "reason": "第一次清仓信号已确认,停止新增买入,等待第二次独立信号",
+ "ref_id": "e7f7eb097cb26ead20fdb6cf6674c4abd1a1ad6768fd8392f110c51aa6af2b8d",
+ "outcome_scored": 0,
+ "book_id": "original",
+ "hard_numbers": {
+ "event": {
+ "version": "timing_fusion_v1",
+ "ts_code": "601126.SH",
+ "source": "timing_fusion",
+ "key": "e7f7eb097cb26ead20fdb6cf6674c4abd1a1ad6768fd8392f110c51aa6af2b8d",
+ "action": "SELL",
+ "score": -0.666666667,
+ "coverage": 2,
+ "groups": {
+ "qrs": {
+ "weight": 0.3333333333333333,
+ "state": "VALID",
+ "direction": -1,
+ "evidence": [
+ {
+ "ts_code": "601126.SH",
+ "group": "qrs",
+ "direction": -1,
+ "at": "2026-11-12T09:30:00+08:00",
+ "expires_at": "2026-11-12T15:00:00+08:00",
+ "identity": "372dc66d4823b83b47aecef68c7e62c1ba3a19025a7cbaff0a9bff35358dcedb",
+ "source": "daily_qrs_symmetric_down"
+ }
+ ]
+ },
+ "main_fund": {
+ "weight": 0.3333333333333333,
+ "state": "UNKNOWN",
+ "direction": 0,
+ "evidence": []
+ },
+ "v3f": {
+ "weight": 0.3333333333333333,
+ "state": "VALID",
+ "direction": -1,
+ "evidence": [
+ {
+ "ts_code": "601126.SH",
+ "group": "v3f",
+ "direction": -1,
+ "at": "2026-11-12T13:56:48+08:00",
+ "expires_at": "2026-11-12T14:41:48+08:00",
+ "identity": "9b4548fc81f478ec3d7fcc717a806254691eb03756577a0af7d5b0b3fe6c9211",
+ "source": "mtf_v3f"
+ }
+ ]
+ }
+ },
+ "at": "2026-11-12T13:56:48+08:00",
+ "verified_at": "2026-11-12T13:57:05.546250+08:00",
+ "expires_at": "2026-11-12T13:59:05.546250+08:00",
+ "reason": "三组独立证据:同向看空"
+ },
+ "count": 1,
+ "round_id": "c4d5ad09d8b4c8720940"
+ }
+ },
+ {
+ "id": 7559,
+ "ts_code": "601126.SH",
+ "decided_at": "2026-11-12 14:42:01",
+ "action": "SIGNAL",
+ "arbiter": "system",
+ "verdict": "NOTE",
+ "price_at": "0.000",
+ "reason": "三组独立证据:证据不足或方向冲突,等待",
+ "ref_id": "0aa18cb19c70fed688865f5dc4b5f1a9520fdd420c0a2938faabce85e6027b4a",
+ "outcome_scored": 0,
+ "book_id": "original",
+ "hard_numbers": {
+ "timing_direction": {
+ "version": "timing_fusion_v1",
+ "ts_code": "601126.SH",
+ "source": "timing_fusion",
+ "key": "0aa18cb19c70fed688865f5dc4b5f1a9520fdd420c0a2938faabce85e6027b4a",
+ "action": "WAIT",
+ "score": -0.333333333,
+ "coverage": 1,
+ "groups": {
+ "qrs": {
+ "weight": 0.3333333333333333,
+ "state": "VALID",
+ "direction": -1,
+ "evidence": [
+ {
+ "ts_code": "601126.SH",
+ "group": "qrs",
+ "direction": -1,
+ "at": "2026-11-12T09:30:00+08:00",
+ "expires_at": "2026-11-12T15:00:00+08:00",
+ "identity": "372dc66d4823b83b47aecef68c7e62c1ba3a19025a7cbaff0a9bff35358dcedb",
+ "source": "daily_qrs_symmetric_down"
+ }
+ ]
+ },
+ "main_fund": {
+ "weight": 0.3333333333333333,
+ "state": "UNKNOWN",
+ "direction": 0,
+ "evidence": []
+ },
+ "v3f": {
+ "weight": 0.3333333333333333,
+ "state": "UNKNOWN",
+ "direction": 0,
+ "evidence": []
+ }
+ },
+ "at": "2026-11-12T09:30:00+08:00",
+ "verified_at": "2026-11-12T14:42:00.119752+08:00",
+ "expires_at": "2026-11-12T14:44:00.119752+08:00",
+ "reason": "三组独立证据:证据不足或方向冲突,等待"
+ }
+ }
+ },
+ {
+ "id": 7571,
+ "ts_code": "601126.SH",
+ "decided_at": "2026-11-12 15:00:01",
+ "action": "SIGNAL",
+ "arbiter": "system",
+ "verdict": "NOTE",
+ "price_at": "0.000",
+ "reason": "三组独立证据:证据不足或方向冲突,等待",
+ "ref_id": "8d58864513852bbb067c47fc263c8c18a2e7c5494d04345f8b81131373e0886d",
+ "outcome_scored": 0,
+ "book_id": "original",
+ "hard_numbers": {
+ "timing_direction": {
+ "version": "timing_fusion_v1",
+ "ts_code": "601126.SH",
+ "source": "timing_fusion",
+ "key": "8d58864513852bbb067c47fc263c8c18a2e7c5494d04345f8b81131373e0886d",
+ "action": "WAIT",
+ "score": 0.0,
+ "coverage": 0,
+ "groups": {
+ "qrs": {
+ "weight": 0.3333333333333333,
+ "state": "UNKNOWN",
+ "direction": 0,
+ "evidence": []
+ },
+ "main_fund": {
+ "weight": 0.3333333333333333,
+ "state": "UNKNOWN",
+ "direction": 0,
+ "evidence": []
+ },
+ "v3f": {
+ "weight": 0.3333333333333333,
+ "state": "UNKNOWN",
+ "direction": 0,
+ "evidence": []
+ }
+ },
+ "at": "2026-11-12T15:00:01.032502+08:00",
+ "verified_at": "2026-11-12T15:00:01.032502+08:00",
+ "expires_at": "2026-11-12T15:01:01.032502+08:00",
+ "reason": "三组独立证据:证据不足或方向冲突,等待"
+ }
+ }
+ },
+ {
+ "id": 7588,
+ "ts_code": "601126.SH",
+ "decided_at": "2026-11-13 09:32:01",
+ "action": "SIGNAL",
+ "arbiter": "system",
+ "verdict": "NOTE",
+ "price_at": "0.000",
+ "reason": "三组独立证据:证据不足或方向冲突,等待",
+ "ref_id": "00837866c4169f942a726886f7e25f066130f0a869a4f588cce4ba50e3d0ed7e",
+ "outcome_scored": 0,
+ "book_id": "original",
+ "hard_numbers": {
+ "timing_direction": {
+ "version": "timing_fusion_v1",
+ "ts_code": "601126.SH",
+ "source": "timing_fusion",
+ "key": "00837866c4169f942a726886f7e25f066130f0a869a4f588cce4ba50e3d0ed7e",
+ "action": "WAIT",
+ "score": -0.333333333,
+ "coverage": 1,
+ "groups": {
+ "qrs": {
+ "weight": 0.3333333333333333,
+ "state": "VALID",
+ "direction": -1,
+ "evidence": [
+ {
+ "ts_code": "601126.SH",
+ "group": "qrs",
+ "direction": -1,
+ "at": "2026-11-13T09:30:00+08:00",
+ "expires_at": "2026-11-13T15:00:00+08:00",
+ "identity": "e155c192986f8d65abf03c58f3787aaaa2398dd4b5a0bc5497bd737a96d6704a",
+ "source": "daily_qrs_symmetric_down"
+ }
+ ]
+ },
+ "main_fund": {
+ "weight": 0.3333333333333333,
+ "state": "UNKNOWN",
+ "direction": 0,
+ "evidence": []
+ },
+ "v3f": {
+ "weight": 0.3333333333333333,
+ "state": "UNKNOWN",
+ "direction": 0,
+ "evidence": []
+ }
+ },
+ "at": "2026-11-13T09:30:00+08:00",
+ "verified_at": "2026-11-13T09:32:00.049057+08:00",
+ "expires_at": "2026-11-13T09:34:00.049057+08:00",
+ "reason": "三组独立证据:证据不足或方向冲突,等待"
+ }
+ }
+ },
+ {
+ "id": 7783,
+ "ts_code": "601126.SH",
+ "decided_at": "2026-11-13 15:00:06",
+ "action": "SIGNAL",
+ "arbiter": "system",
+ "verdict": "NOTE",
+ "price_at": "0.000",
+ "reason": "三组独立证据:证据不足或方向冲突,等待",
+ "ref_id": "f96bc56b1a9a389d1fb053cb386c2cdf2c63ee938f3b633537be8224f5a2a0fd",
+ "outcome_scored": 0,
+ "book_id": "original",
+ "hard_numbers": {
+ "timing_direction": {
+ "version": "timing_fusion_v1",
+ "ts_code": "601126.SH",
+ "source": "timing_fusion",
+ "key": "f96bc56b1a9a389d1fb053cb386c2cdf2c63ee938f3b633537be8224f5a2a0fd",
+ "action": "WAIT",
+ "score": 0.0,
+ "coverage": 0,
+ "groups": {
+ "qrs": {
+ "weight": 0.3333333333333333,
+ "state": "UNKNOWN",
+ "direction": 0,
+ "evidence": []
+ },
+ "main_fund": {
+ "weight": 0.3333333333333333,
+ "state": "UNKNOWN",
+ "direction": 0,
+ "evidence": []
+ },
+ "v3f": {
+ "weight": 0.3333333333333333,
+ "state": "UNKNOWN",
+ "direction": 0,
+ "evidence": []
+ }
+ },
+ "at": "2026-11-13T15:00:05.499280+08:00",
+ "verified_at": "2026-11-13T15:00:05.499280+08:00",
+ "expires_at": "2026-11-13T15:01:05.499280+08:00",
+ "reason": "三组独立证据:证据不足或方向冲突,等待"
+ }
+ }
+ },
+ {
+ "id": 7811,
+ "ts_code": "601126.SH",
+ "decided_at": "2026-11-16 09:32:04",
+ "action": "SIGNAL",
+ "arbiter": "system",
+ "verdict": "NOTE",
+ "price_at": "0.000",
+ "reason": "三组独立证据:证据不足或方向冲突,等待",
+ "ref_id": "63a2f3b523052fc404636ec7e886bd6a01234729a0466cf29c35f9c8c5b85031",
+ "outcome_scored": 0,
+ "book_id": "original",
+ "hard_numbers": {
+ "timing_direction": {
+ "version": "timing_fusion_v1",
+ "ts_code": "601126.SH",
+ "source": "timing_fusion",
+ "key": "63a2f3b523052fc404636ec7e886bd6a01234729a0466cf29c35f9c8c5b85031",
+ "action": "WAIT",
+ "score": -0.333333333,
+ "coverage": 1,
+ "groups": {
+ "qrs": {
+ "weight": 0.3333333333333333,
+ "state": "VALID",
+ "direction": -1,
+ "evidence": [
+ {
+ "ts_code": "601126.SH",
+ "group": "qrs",
+ "direction": -1,
+ "at": "2026-11-16T09:30:00+08:00",
+ "expires_at": "2026-11-16T15:00:00+08:00",
+ "identity": "5ba6fa755e77cf4b0cde2111f68fcb1f7fd5c2818c15ab52ca06cb5d04d00080",
+ "source": "daily_qrs_symmetric_down"
+ }
+ ]
+ },
+ "main_fund": {
+ "weight": 0.3333333333333333,
+ "state": "UNKNOWN",
+ "direction": 0,
+ "evidence": []
+ },
+ "v3f": {
+ "weight": 0.3333333333333333,
+ "state": "UNKNOWN",
+ "direction": 0,
+ "evidence": []
+ }
+ },
+ "at": "2026-11-16T09:30:00+08:00",
+ "verified_at": "2026-11-16T09:32:03.942316+08:00",
+ "expires_at": "2026-11-16T09:34:03.942316+08:00",
+ "reason": "三组独立证据:证据不足或方向冲突,等待"
+ }
+ }
+ }
+ ]
+ },
+ "603259.SH": {
+ "risk_exit": {
+ "book_id": "original",
+ "code": "603259.SH",
+ "count": 0,
+ "events": [],
+ "exit_seq": 0,
+ "initialized_at": "2026-11-06T09:57:02.207649+08:00",
+ "lot_ids": [
+ "1457"
+ ],
+ "opened_date": "2026-11-06",
+ "phase": "WATCH",
+ "review": {
+ "at": "2026-11-05T12:34:32.085489+08:00",
+ "grade": "好",
+ "ref": "09942b49613cf22d1b1f5008593a2dde19011d3248c6864d8cb2b0bf344ecb74"
+ },
+ "round_id": "cbfbb3748fe303d9c7b4",
+ "stopped_parents": [
+ "INS_20261106_603259SH_OPEN_001_feed045bd695"
+ ]
+ },
+ "timing": null,
+ "ledger": []
+ }
+ }
+}
diff --git a/scripts/test_batch49_units.py b/scripts/test_batch49_units.py
index ed98cea..652a113 100644
--- a/scripts/test_batch49_units.py
+++ b/scripts/test_batch49_units.py
@@ -168,5 +168,53 @@ class InstructionBooksTests(unittest.TestCase):
cancel.assert_not_called()
+class PositionCurrentTechTests(unittest.TestCase):
+ def setUp(self):
+ install_fakes()
+ from app.web import main
+ from app.services import tech_service, consensus_service, logic_state_service, command_service, risk_exit
+ self.main = main
+ self.row = {'ts_code': '601126.SH', 'total_qty': 2700, 'tech': {'stance': '看多', 'data_date': 20261112}}
+ self.enterContext(patch.object(portfolio, 'positions_view', return_value={'positions': [self.row]}))
+ self.enterContext(patch.object(portfolio, 'position_groups', return_value=[]))
+ self.enterContext(patch.object(risk_exit, 'decorate_positions'))
+ self.enterContext(patch.object(command_service, 'effective_stock_params', return_value={}))
+ self.enterContext(patch.object(command_service, 'attach_user_prices'))
+ self.enterContext(patch.object(logic_state_service, 'decorate_positions'))
+ self.enterContext(patch.object(logic_state_service, 'state_map', return_value={}))
+ self.read = self.enterContext(patch.object(tech_service, 'read_states_for'))
+ def decorate(rows, **kwargs):
+ self.seen = kwargs['tech_states']
+ for row in rows:
+ row['consensus_blocks'] = {'tech': self.seen.get(row['ts_code']) or {'stance': '无读数'}}
+ self.enterContext(patch.object(consensus_service, 'decorate_positions', side_effect=decorate))
+ self.old = self.enterContext(patch.object(tech_service, 'state_map', side_effect=AssertionError('不能回退旧映射')))
+
+ def test_current_date_replaces_older_bullish_map_in_list_and_detail_fields(self):
+ latest = {'stance': '中性', 'phase': '分歧', 'data_date': 20261113}
+ self.read.return_value = {'601126.SH': latest}
+ result = self.main.api_positions()
+ self.assertTrue(result['ok'])
+ self.assertEqual(result['positions'][0]['tech'], latest)
+ self.assertEqual(result['positions'][0]['dims']['tech'], '中性')
+ self.assertEqual(self.seen['601126.SH'], latest)
+ self.old.assert_not_called()
+
+ def test_read_failure_does_not_restore_old_bullish_map(self):
+ self.read.side_effect = ValueError('isolated read failed')
+ result = self.main.api_positions()
+ self.assertTrue(result['ok'])
+ self.assertIsNone(result['positions'][0]['tech'])
+ self.assertEqual(result['positions'][0]['dims']['tech'], '无读数')
+ self.assertEqual(self.seen, {})
+ self.old.assert_not_called()
+
+ def test_expired_current_data_does_not_restore_old_bullish_map(self):
+ self.read.return_value = {}
+ result = self.main.api_positions()
+ self.assertEqual(result['positions'][0]['dims']['tech'], '无读数')
+ self.old.assert_not_called()
+
+
if __name__ == '__main__':
unittest.main()
diff --git a/scripts/test_risk_exit.py b/scripts/test_risk_exit.py
index ddf1ddc..ccffad2 100644
--- a/scripts/test_risk_exit.py
+++ b/scripts/test_risk_exit.py
@@ -411,6 +411,11 @@ class ServiceTests(unittest.TestCase):
class DisplayTests(unittest.TestCase):
+ def setUp(self):
+ from app.services import timing_state, timing_fusion
+ self.latest = self.enterContext(patch.object(timing_state, 'latest', return_value=None))
+ self.enterContext(patch.object(timing_fusion, 'enabled', return_value=True))
+
def test_first_stop_without_strategy_is_visible(self):
rows=[{'ts_code':CODE,'total_qty':100}]
with patch.object(service,'supported',return_value=True), patch.object(service,'enabled',return_value=True), patch.object(store,'get',return_value=({'phase':'STOP_BUY','reason':'第一次信号'},1)):
@@ -436,5 +441,90 @@ class DisplayTests(unittest.TestCase):
with patch.object(service,'supported',return_value=True), patch.object(service,'enabled',return_value=True), patch.object(store,'get') as get:
service.decorate_positions([{'ts_code':CODE,'total_qty':0}]);get.assert_not_called()
+ def test_timing_read_failure_preserves_stop_and_original_reason(self):
+ self.latest.side_effect = ValueError('unavailable')
+ rows = [{'ts_code': CODE, 'total_qty': 100}]
+ state = {'phase': 'STOP_BUY', 'reason': '首次停买原文'}
+ with patch.object(service, 'supported', return_value=True), patch.object(service, 'enabled', return_value=True), patch.object(store, 'get', return_value=(state, 1)):
+ service.decorate_positions(rows, now=NOW)
+ self.assertEqual(rows[0]['exit_status_text'], '只卖不买')
+ self.assertEqual(rows[0]['exit_status_reason'], '首次停买原文')
+ self.assertIn('读取失败', rows[0]['exit_detail']['current'])
+ self.assertEqual(state, {'phase': 'STOP_BUY', 'reason': '首次停买原文'})
+
+
+class ExitPresentationTests(unittest.TestCase):
+ def event(self, action='SELL', at=NOW, n=1):
+ from app.core import timing_fusion_contract as contract
+ sign = {'SELL': -1, 'BUY': 1, 'WAIT': 0}[action]
+ groups = {name: {'weight': 1/3, 'direction': sign, 'state': 'VALID', 'evidence': [
+ {'group': name, 'ts_code': CODE, 'at': at.isoformat(),
+ 'expires_at': (at+dt.timedelta(minutes=30)).isoformat(), 'identity': core.digest([name, n])}]}
+ for name in contract.GROUPS}
+ return {'source': 'timing_fusion', 'version': contract.VERSION, 'ts_code': CODE,
+ 'key': core.digest([action, n]), 'action': action, 'score': sign,
+ 'at': at.isoformat(), 'verified_at': at.isoformat(),
+ 'expires_at': (at+dt.timedelta(seconds=100)).isoformat(), 'groups': groups}
+
+ def render(self, current=None, state=None, now=NOW):
+ from app.core.exit_presentation import view
+ return view(state or {'phase': 'STOP_BUY', 'events': [self.event()]}, current,
+ fusion_enabled=True, now=now)
+
+ def test_expired_cannot_displace_valid_current_or_become_neutral(self):
+ self.assertIn('没有有效', self.render(self.event(), now=NOW+dt.timedelta(minutes=2))['current'])
+ fresh = self.event('BUY', NOW+dt.timedelta(minutes=2), 2)
+ self.assertIn('当前择时看多', self.render(fresh, now=NOW+dt.timedelta(minutes=2))['current'])
+ self.assertIn('仍待', self.render(fresh, now=NOW+dt.timedelta(minutes=2))['current'])
+
+ def test_unknown_is_not_neutral(self):
+ e = self.event('WAIT')
+ for g in e['groups'].values():
+ g.update(state='UNKNOWN', evidence=[])
+ self.assertEqual(self.render(e)['current'].count('暂不可用'), 3)
+ self.assertNotIn('中性', self.render(e)['current'])
+
+ def test_wait_shows_neutral_conflict_and_partial_coverage(self):
+ e = self.event('WAIT')
+ self.assertEqual(self.render(e)['current'].count('中性'), 3)
+ e['groups']['qrs']['direction'] = -1
+ e['groups']['main_fund']['direction'] = 1
+ e['groups']['v3f'].update(state='UNKNOWN', evidence=[])
+ detail = self.render(e)['current']
+ self.assertIn('量化择时看空', detail)
+ self.assertIn('主力资金看多', detail)
+ self.assertIn('资金异动暂不可用', detail)
+ self.assertIn('尚未形成', detail)
+
+ def test_duplicate_and_one_new_group_cannot_be_displayed_as_confirmation(self):
+ old = self.event()
+ self.assertIn('不足以构成第二次', self.render(old)['current'])
+ later = NOW+dt.timedelta(seconds=30)
+ fresh = self.event(at=later, n=2)
+ fresh['groups']['qrs'] = old['groups']['qrs']
+ fresh['groups']['v3f'] = old['groups']['v3f']
+ self.assertIn('不足以构成第二次', self.render(fresh, now=later)['current'])
+
+ def test_two_new_groups_wait_for_existing_state_machine_not_fake_exit(self):
+ later = NOW+dt.timedelta(seconds=30)
+ detail = self.render(self.event(at=later, n=2), now=later)
+ self.assertEqual(detail['status'], '只卖不买')
+ self.assertIn('等待退出纪律处理', detail['current'])
+
+ def test_original_audit_unchanged_and_legacy_first_supported(self):
+ state = {'phase': 'STOP_BUY', 'events': [{'source': 'intraday', 'at': NOW.isoformat(), 'reason': '原始依据'}]}
+ before = copy.deepcopy(state)
+ detail = self.render(self.event(), state)
+ self.assertEqual(detail['first_reason'], '原始依据')
+ self.assertEqual(detail['first_at'], '2026-11-05 10:00:00')
+ self.assertEqual(state, before)
+
+ def test_exit_and_manual_stop_do_not_wait_for_second_signal(self):
+ for phase in ('EXIT_PENDING', 'EXITING', 'MANUAL', 'CLOSED'):
+ detail = self.render(state={'phase': phase, 'user_stop': {'price': 10}, 'reason': '人工止损触价'})
+ self.assertNotIn('current', detail)
+ self.assertNotIn('第二次', detail['next'])
+ self.assertEqual(detail['reason'], '人工止损触价')
+
if __name__=='__main__':unittest.main()