恢复阈值变色柱图并区分待执行指令与真实委托

This commit is contained in:
baobao 2026-10-28 10:49:00 +08:00
parent 38cbc19d30
commit 5e1ae075e3
4 changed files with 93 additions and 62 deletions

View File

@ -105,29 +105,45 @@ def instruction_progress(rows):
continue
if not ws:
row['execution_label'] = '影子执行待核对'
row['execution_stage'] = 'shadow'
continue
try:
orders = qmt_repo.orders_for_parent(row['instruction_id'])
active = [o for o in orders if o.get('status') in qmt_repo.LIVE]
stage = 'waiting'
if any(o.get('cancel_state') in ('REQUESTED', 'SENT') for o in active):
label = '撤单处理中'
stage = 'cancelling'
elif any(o.get('status') not in ('QUEUED', 'SENDING') for o in active):
label = '委托待成交'
stage = 'submitted'
elif active:
label = '委托待发送'
stage = 'sending' if any(o.get('status') == 'SENDING' for o in active) else 'queued'
else:
reason = ((row.get('progress') or {}).get('last_decision') or {}).get('reason') or ''
decision = (row.get('progress') or {}).get('last_decision') or {}
reason = decision.get('reason') or ''
if row.get('status') == 'CANCELLED':
label = '已撤销'
stage = 'ended'
elif sum(int(o.get('cum_qty') or 0) for o in orders) >= int(row.get('qty') or 1):
label = '成交待入账'
stage = 'reconciling'
elif '可卖量不足' in reason:
label = '等待可卖'
elif '当日配额' in reason:
label = '等待下一批'
elif '暂停买入' in reason:
label = '买入已暂停'
elif decision.get('action') == 'REJECT':
label = '执行检查未通过'
elif decision.get('action') in ('WAIT', 'SKIP', 'STOP'):
label = '等待买入条件' if row.get('side') == 'buy' else '等待卖出条件'
else:
label = '等待执行'
row['execution_label'] = label
row['execution_stage'] = stage
except Exception:
row['execution_label'] = '委托状态待核实'
row['execution_stage'] = 'unknown'
return rows

View File

@ -43,7 +43,7 @@ body{margin:0;background:var(--plane);color:var(--ink);
.hst.entry{background:var(--up-weak);color:var(--up);}
.hst.exit{background:var(--down-weak);color:var(--down);}
.hst.missing{background:transparent;color:var(--muted);outline:1px dashed var(--muted);outline-offset:-1px;}
.market-popover{width:min(440px,calc(100vw - 44px));font-size:12px;line-height:1.5;}
.market-popover{width:min(360px,calc(100vw - 44px));font-size:12px;line-height:1.5;}
.market-popover .trend-heading{display:flex;justify-content:space-between;align-items:center;gap:8px;margin-bottom:5px;}
.market-popover .trend-heading b{font-size:13px;}
.market-popover .trend-value{font-size:19px;font-weight:650;}
@ -605,17 +605,14 @@ body.dock-r:not(.r-fold) .side-r .strip{display:none;}
<div class="trend-heading"><span>执行值 <b class="trend-value mono">{{ microNumber(mzSig.value) }}</b></span><span class="muted">发布值 {{ mzPublished.ready ? microNumber(mzPublished.value) : '待核实' }}</span></div>
<div class="trend-meta"><span>数据 {{ mzDate(mzSig.data_ymd) }}</span><span>发布 {{ mzPublished.ready ? mzDate(mzPublished.data_ymd) : '未知' }}</span></div>
<div v-for="chart in [macroChart]" :key="chart.title" class="trend-section">
<div class="trend-legend"><span v-for="line in chart.lines.filter(l => !l.hideLegend)" :key="line.name" class="trend-key"><i :class="{dashed:line.dash}" :style="{borderColor:line.color}"></i>{{ line.name }}</span></div>
<svg v-if="chart.available" viewBox="0 0 440 148" role="img" :aria-label="chart.title + '趋势'">
<g v-for="tick in chart.ticks" :key="tick.label"><line x1="40" x2="426" :y1="tick.y" :y2="tick.y" stroke="var(--hair)"></line><text x="33" :y="tick.y+3" text-anchor="end">{{ tick.label }}</text></g>
<path v-for="line in chart.lines" :key="line.name" :d="line.path" fill="none" :stroke="line.color" :stroke-width="line.dash ? 1 : 2" :stroke-dasharray="line.dash ? '4 4' : null" stroke-linejoin="round"></path>
<g v-for="point in chart.dots" :key="point.key"><circle :cx="point.x" :cy="point.y" r="2.4" :fill="point.color"></circle></g>
<rect v-for="point in chart.hover" :key="point.date" :x="point.x" y="12" :width="point.width" height="110" fill="transparent"><title>{{ point.text }}</title></rect>
<text x="40" y="141">{{ chart.first }}</text><text x="233" y="141" text-anchor="middle">{{ chart.middle }}</text><text x="426" y="141" text-anchor="end">{{ chart.last }}</text>
<svg v-if="chart.available" viewBox="0 0 440 92" role="img" :aria-label="chart.title + '柱状趋势'">
<line x1="4" x2="436" :y1="chart.zero" :y2="chart.zero" stroke="var(--hair)"></line>
<rect v-for="bar in chart.bars" :key="bar.key" class="trend-bar" :x="bar.x" :y="bar.y" :width="bar.width" :height="bar.height" rx="1.5" :fill="bar.color" :stroke="bar.missing ? 'var(--muted)' : 'none'" :stroke-dasharray="bar.missing ? '2 2' : null"><title>{{ bar.text }}</title></rect>
<text x="4" y="88">{{ chart.first }}</text><text x="436" y="88" text-anchor="end">{{ chart.last }}</text>
</svg>
<div v-else class="trend-empty">暂无有效趋势数据</div>
</div>
<div class="trend-foot">冷 {{ (macro.params||{}).cold_th }} · 热 +{{ (macro.params||{}).hot_th }} · 退出 ±{{ (macro.params||{}).exit_band }}<span v-if="mzDifferent"> · 两值有差异,按执行值择时</span></div>
<div class="trend-foot"><span style="color:#3d7ff0">冷 &lt; {{ (macro.params||{}).cold_th }}</span> · <span style="color:#d8574a">热 &gt; +{{ (macro.params||{}).hot_th }}</span><span v-if="mzDifferent"> · 两值有差异,按执行值择时</span></div>
<div v-if="macroGateOn" class="trend-foot" style="color:var(--warn)">偏热,自动买入暂停</div>
<div v-if="mzAdvicePending" class="trend-foot"><b>{{ mzSig.advice.direction==='REDUCE' ? '降仓' : '升仓' }}建议 {{ (mzSig.advice.pct*100).toFixed(1) }}%</b> <button class="tbtn pri" @click="macroAdopt(mzSig.key)">采纳并下命令</button></div>
<div v-show="mode==='ops'" class="trend-foot"><button class="tbtn" @click="macroScan(true)">试算一遍</button> <button class="tbtn" @click="macroScan(false)">立即扫描</button></div>
@ -633,18 +630,15 @@ body.dock-r:not(.r-fold) .side-r .strip{display:none;}
<div v-if="microError" class="trend-foot" style="color:var(--warn)">{{ microError }}</div>
<div v-for="chart in microCharts" :key="chart.title" class="trend-section">
<div class="trend-heading"><b>{{ chart.title }}</b><span class="mono">{{ chart.current }}</span></div>
<div class="trend-legend"><span v-for="line in chart.lines.filter(l => !l.hideLegend)" :key="line.name" class="trend-key"><i :class="{dashed:line.dash}" :style="{borderColor:line.color}"></i>{{ line.name }}</span></div>
<svg v-if="chart.available" viewBox="0 0 440 148" role="img" :aria-label="chart.title + '趋势'">
<g v-for="tick in chart.ticks" :key="tick.label"><line x1="40" x2="426" :y1="tick.y" :y2="tick.y" stroke="var(--hair)"></line><text x="33" :y="tick.y+3" text-anchor="end">{{ tick.label }}</text></g>
<path v-for="line in chart.lines" :key="line.name" :d="line.path" fill="none" :stroke="line.color" :stroke-width="line.dash ? 1 : 2" :stroke-dasharray="line.dash ? '4 4' : null" stroke-linejoin="round"></path>
<g v-for="point in chart.dots" :key="point.key"><circle :cx="point.x" :cy="point.y" r="2.4" :fill="point.color"></circle></g>
<rect v-for="point in chart.hover" :key="point.date" :x="point.x" y="12" :width="point.width" height="110" fill="transparent"><title>{{ point.text }}</title></rect>
<text x="40" y="141">{{ chart.first }}</text><text x="233" y="141" text-anchor="middle">{{ chart.middle }}</text><text x="426" y="141" text-anchor="end">{{ chart.last }}</text>
<svg v-if="chart.available" viewBox="0 0 440 92" role="img" :aria-label="chart.title + '柱状趋势'">
<line x1="4" x2="436" :y1="chart.zero" :y2="chart.zero" stroke="var(--hair)"></line>
<rect v-for="bar in chart.bars" :key="bar.key" class="trend-bar" :x="bar.x" :y="bar.y" :width="bar.width" :height="bar.height" rx="1.5" :fill="bar.color" :stroke="bar.missing ? 'var(--muted)' : 'none'" :stroke-dasharray="bar.missing ? '2 2' : null"><title>{{ bar.text }}</title></rect>
<text x="4" y="88">{{ chart.first }}</text><text x="436" y="88" text-anchor="end">{{ chart.last }}</text>
</svg>
<div v-else class="trend-empty">暂无有效趋势数据</div>
</div>
<div v-if="microHistoryError" class="trend-foot" style="color:var(--warn)">{{ microHistoryError }}</div>
<div class="trend-foot">低于5%入场 · 高于95%退出 · 成长瓦解 {{ microReady ? microSignal.growth_break ? '已触发' : '未触发' : '待核实' }}</div>
<div class="trend-foot"><span style="color:#d8574a">低于5%入场</span> · <span style="color:#158a4c">高于95%退出</span> · 成长瓦解 {{ microReady ? microSignal.growth_break ? '已触发' : '未触发' : '待核实' }}</div>
<div class="trend-meta" style="margin-top:6px"><span>历史按当前数据计算</span><a href="/rotation">策略详情 →</a></div>
</div>
</template>
@ -722,7 +716,7 @@ body.dock-r:not(.r-fold) .side-r .strip{display:none;}
<div class="mb-latest">
<template v-if="msgLatest">
<span class="mono muted" style="font-size:11.5px">{{ msgLatest.time || '—' }}</span>
<span class="mb-kind" :class="'k-'+msgLatest.kind" style="width:auto;padding:1px 6px">{{ kindLabel(msgLatest.kind) }}</span>
<span class="mb-kind" :class="'k-'+msgLatest.kind" style="width:auto;padding:1px 6px">{{ msgLatest.badge || kindLabel(msgLatest.kind) }}</span>
<span class="txt">
<b v-if="msgLatest.ts_code" style="cursor:pointer;text-decoration:underline dotted"
title="点一下看这只票今天的全部信号"
@ -748,8 +742,8 @@ body.dock-r:not(.r-fold) .side-r .strip{display:none;}
</div>
<div class="mb-empty" v-if="!msgShown.length">这一类今天还没有消息。</div>
<div v-for="(m,i) in msgShown.slice(0,120)" :key="i" class="mb-row" :class="{'alert-stale':m.stale}">
<span class="t mono">{{ m.time || '—' }}</span>
<span class="mb-kind" :class="'k-'+m.kind">{{ kindLabel(m.kind) }}</span>
<span class="t mono" :title="m.kind==='order' ? '指令进度更新时间' : ''">{{ m.time || '—' }}</span>
<span class="mb-kind" :class="'k-'+m.kind">{{ m.badge || kindLabel(m.kind) }}</span>
<div class="body">
<b v-if="m.ts_code" style="cursor:pointer;text-decoration:underline dotted"
title="点一下看这只票今天的全部信号"
@ -1199,7 +1193,7 @@ body.dock-r:not(.r-fold) .side-r .strip{display:none;}
<el-table :data="insLive" size="small" max-height="280" empty-text="现在没有未成交的买卖单">
<el-table-column label="股票" min-width="150"><template #default="s"><b>{{ nm(s.row.ts_code) }}</b> <span class="muted mono">{{ s.row.ts_code }}</span></template></el-table-column>
<el-table-column label="做什么" width="150"><template #default="s">{{ tx('action', s.row.action) }} · {{ tx('side', s.row.side) }}</template></el-table-column>
<el-table-column label="下单量 / 已成交" width="130" align="right"><template #default="s"><span class="mono">{{ s.row.qty }} / {{ s.row.exec_qty||0 }}</span></template></el-table-column>
<el-table-column label="计划量 / 已成交" width="130" align="right"><template #default="s"><span class="mono">{{ s.row.qty }} / {{ s.row.exec_qty||0 }}</span></template></el-table-column>
<el-table-column label="限价" width="82" align="right"><template #default="s"><span class="mono">{{ s.row.limit_price||'—' }}</span></template></el-table-column>
<el-table-column label="进展" min-width="130"><template #default="s"><span class="chip idle"><span class="dot"></span>{{ s.row.execution_label || tx('insStatus', s.row.status) }}</span></template></el-table-column>
<el-table-column label="操作" width="76"><template #default="s"><button class="tbtn sm" @click="cancelIns(s.row.instruction_id)">撤单</button></template></el-table-column>
@ -1210,7 +1204,7 @@ body.dock-r:not(.r-fold) .side-r .strip{display:none;}
<el-table :data="insDone" size="small" max-height="280" empty-text="今天还没有成交">
<el-table-column label="股票" min-width="150"><template #default="s"><b>{{ nm(s.row.ts_code) }}</b> <span class="muted mono">{{ s.row.ts_code }}</span></template></el-table-column>
<el-table-column label="做什么" width="150"><template #default="s">{{ tx('action', s.row.action) }} · {{ tx('side', s.row.side) }}</template></el-table-column>
<el-table-column label="下单量 / 已成交" width="130" align="right"><template #default="s"><span class="mono">{{ s.row.qty }} / {{ s.row.exec_qty||0 }}</span></template></el-table-column>
<el-table-column label="计划量 / 已成交" width="130" align="right"><template #default="s"><span class="mono">{{ s.row.qty }} / {{ s.row.exec_qty||0 }}</span></template></el-table-column>
<el-table-column label="进展" min-width="130"><template #default="s"><span class="chip ok"><span class="dot"></span>{{ s.row.execution_label || tx('insStatus', s.row.status) }}</span></template></el-table-column>
</el-table>
</el-tab-pane>
@ -3007,7 +3001,7 @@ createApp({
lot: { BASE:'首批', FILL:'回落补足', ADD:'盈利加仓', DCA:'浮亏补仓', T0:'做T仓', RECON:'对账修正' },
frozen: { NONE:'', COMMAND_HALT:'命令要求只卖不买', BRAKE:'组合刹车,只卖不买', MANUAL:'人工冻结,只卖不买' },
posStatus: { PLANNED:'计划建仓', OPENING:'建仓中', HOLDING:'持有中', EXITING:'清仓中', CLOSED:'已清仓' },
insStatus: { PROPOSED:'待校验', RULE_PASSED:'合规检查已过', JUDGE_PASSED:'决策系统复核已过', DISPATCHED:'执行中',
insStatus: { PROPOSED:'待执行检查', RULE_PASSED:'合规检查已过', JUDGE_PASSED:'决策系统复核已过', DISPATCHED:'执行中',
CONFIRMED:'已成交', REJECTED:'已拦截', EXPIRED:'到期作废', CANCELLED:'已撤销' },
arbiter: { rule:'合规检查', judge:'决策系统', user:'人工', system:'系统自动' },
// 这一组是**评审账本**的结论,只有四个值。研判闸的结论是另一组 judgeVerdict,
@ -3268,7 +3262,7 @@ createApp({
if (inst) {
// 系统自决自动采纳的指令 (2026-09-14): 进度里 auto 为真且理由以「系统采纳」开头, 显示「系统已采纳」。
const autoAcc = inst.progress && inst.progress.auto && String(inst.progress.reason || '').startsWith('系统采纳');
return { cls: 'done', label: autoAcc ? '系统已采纳' : '已下单', why: '在『当日指令』(' + tx('insStatus', inst.status) + ')' };
return { cls: 'done', label: autoAcc ? '系统已采纳' : insBadge(inst), why: '在『当日指令』(' + (inst.execution_label || tx('insStatus', inst.status)) + ')' };
}
const prop = (proposals.value || []).find(p => p.ts_code === code && p.action === 'OPEN');
if (prop) return { cls: 'queue', label: '待确认', why: '已生成提议,在『待确认提议』等人工裁决' };
@ -4392,42 +4386,28 @@ createApp({
} catch (e) { microHistoryError.value = '历史趋势暂不可用'; }
}
// 统一画出真实正负值与缺口,不把空值变成零,不截断极值。
function trendChart(title, rows, specs, percent=false, domain=null) {
// 每日一柱;保留符号与缺数位置,颜色只由当日阈值决定。
function barTrend(title, rows, valueOf, colorOf, percent=false) {
const valid = v => v != null && v !== '' && Number.isFinite(Number(v));
const fmt = v => valid(v) ? (percent ? Number(v).toFixed(1)+'%' : Number(v).toFixed(2)) : '缺失';
const values = specs.flatMap(l => rows.map(l.value).filter(valid).map(Number));
let lo = domain ? domain[0] : Math.min(0,...values), hi = domain ? domain[1] : Math.max(0,...values);
if (hi===lo) hi=lo+1;
if (!domain) { const step=Math.pow(10,Math.floor(Math.log10(hi-lo)))/2;lo=Math.floor(lo/step)*step;hi=Math.ceil(hi/step)*step;if(hi===lo)hi=lo+step; }
const x = i => rows.length===1 ? 233 : 40+i*386/(rows.length-1), y = v => 122-(Number(v)-lo)/(hi-lo)*110;
const dots=[],lines=specs.map(l => {
let path='',pen=false;
rows.forEach((r,i)=>{ const v=l.value(r);if(!valid(v)){pen=false;return;}path+=(pen?' L':' M')+x(i).toFixed(2)+' '+y(v).toFixed(2);pen=true;
if(!l.dash && (i===rows.length-1 || rows.length===1))dots.push({key:l.name+i,x:x(i),y:y(v),color:l.color}); });
return {...l,path};
});
const labels=[lo,(lo+hi)/2,hi], dates=rows.map(r=>String(r.date||''));
const width=rows.length>1 ? 386/(rows.length-1) : 386;
return {title,lines,dots,available:rows.some(r=>specs.some(l=>!l.dash && valid(l.value(r)))),
ticks:labels.map(v=>({y:y(v),label:fmt(v)})),first:dates[0]||'',middle:dates[Math.floor(dates.length/2)]||'',last:dates[dates.length-1]||'',
hover:rows.map((r,i)=>({date:r.date,x:Math.max(40,x(i)-width/2),width:Math.min(426,x(i)+width/2)-Math.max(40,x(i)-width/2),text:r.date+'\n'+specs.map(l=>l.name+' '+fmt(l.value(r))).join('\n')}))};
const values=rows.map(valueOf).filter(valid).map(Number);
const low=percent?0:Math.min(0,...values), high=percent?100:Math.max(0,...values);
const span=high-low || 1, y=v=>70-(Number(v)-low)/span*62, zero=y(0);
const slot=432/Math.max(1,rows.length), gap=Math.min(3,slot*.28);
return {title,available:values.length>0,zero,first:(rows[0]||{}).date||'',last:(rows[rows.length-1]||{}).date||'',
bars:rows.map((r,i)=>{const raw=valueOf(r),missing=!valid(raw),v=missing?0:Number(raw),end=y(v);
return {key:i,x:4+i*slot+gap/2,width:Math.max(1,slot-gap),y:missing?zero-3:Math.min(zero,end),height:missing?3:Math.max(1,Math.abs(end-zero)),
color:missing?'transparent':colorOf(r,v),missing,text:r.date+' · '+(missing?'缺失':percent?v.toFixed(2)+'%':v.toFixed(4))};})};
}
const macroChart = computed(() => {
const p=macro.value.params||{}, rows=((mzSig.value||{}).history||[]).map(r=>({...r,date:mzDate(r.data_ymd||r.ymd)}));
return trendChart('股汇执行值',rows,[{name:'执行值',color:'#397bcc',value:r=>r.value},
{name:'冷/热线',color:'#b78538',dash:true,value:()=>p.hot_th}, {name:'冷线',hideLegend:true,color:'#b78538',dash:true,value:()=>p.cold_th},
{name:'退出带',color:'#a7aaa6',dash:true,value:()=>p.exit_band}, {name:'退出下沿',hideLegend:true,color:'#a7aaa6',dash:true,value:()=>p.exit_band==null?null:-p.exit_band}]);
const p=macro.value.params||{},rows=((mzSig.value||{}).history||[]).map(r=>({...r,date:mzDate(r.data_ymd||r.ymd)}));
return barTrend('股汇执行值',rows,r=>r.value,(r,v)=>p.hot_th!=null&&v>p.hot_th?'#d8574a':p.cold_th!=null&&v<p.cold_th?'#3d7ff0':'#969ba7');
});
const microCharts = computed(() => {
const rows=microHistory.value, g=microSignal.value;
const a=trendChart('微盘活跃度',rows,[{name:'活跃度',color:'#397bcc',value:r=>r.activity},
{name:'5%低位线',color:'#d06458',dash:true,value:r=>r.low_threshold}, {name:'95%高位线',color:'#379068',dash:true,value:r=>r.high_threshold}]);
const rows=microHistory.value,g=microSignal.value;
const color=(r,v,low,high)=>low!=null&&v<low?'#d8574a':high!=null&&v>high?'#158a4c':'#969ba7';
const a=barTrend('微盘活跃度',rows,r=>r.activity,(r,v)=>color(r,v,r.low_threshold,r.high_threshold));
a.current=microReady.value?microNumber(g.activity):'—';
const pc=(r,k)=>{const v=(r.group_percentiles||{})[k];return v==null?null:Number(v)*100;};
const b=trendChart('活跃度历史分位',rows,[{name:'微盘',color:'#397bcc',value:r=>r.activity_percentile==null?null:r.activity_percentile*100},
{name:'成长',color:'#b48b44',value:r=>pc(r,'growth')},{name:'白马',color:'#9a9ea7',value:r=>pc(r,'large')},
{name:'5%',color:'#d06458',dash:true,value:()=>5},{name:'95%',color:'#379068',dash:true,value:()=>95}],true,[0,100]);
const b=barTrend('活跃度历史分位',rows,r=>r.activity_percentile==null?null:r.activity_percentile*100,(r,v)=>color(r,v,5,95),true);
b.current=microReady.value?microPercent(g.activity_percentile):'—';return [a,b];
});
@ -4913,11 +4893,11 @@ createApp({
const MSG_KINDS = [
{ key:'all', label:'全部' },
{ key:'alert', label:'行情告警' },
{ key:'order', label:'系统下单' },
{ key:'order', label:'交易指令' },
{ key:'prop', label:'待确认提议' },
{ key:'strat', label:'策略与风控' },
];
const KIND_LABEL = { alert:'告警', order:'下单', prop:'待办', strat:'风控' };
const KIND_LABEL = { alert:'告警', order:'指令', prop:'待办', strat:'风控' };
const kindLabel = k => KIND_LABEL[k] || k;
const hm = v => { const m = String(v || '').match(/\d{2}:\d{2}/); return m ? m[0] : (v || ''); };
const msgOpen = ref(false), msgKind = ref('all');
@ -4927,12 +4907,22 @@ createApp({
const _hms = s => { const m = String(s || '').match(/(\d{2}):(\d{2})(?::(\d{2}))?/);
return m ? (m[1] + m[2] + (m[3] || '00')) : ''; };
function insBadge(r) {
if (r.execution_stage==='unknown') return '待核对';
if (r.execution_stage==='cancelling') return '撤单中';
if (r.execution_stage==='reconciling') return '待入账';
if (r.status==='CONFIRMED') return '成交';
if (['CANCELLED','REJECTED','EXPIRED'].includes(r.status)) return '已终止';
return {submitted:'委托',sending:'发送中',queued:'待发送',waiting:'待执行',shadow:'待核对'}[r.execution_stage] || (_LIVE_INS.includes(r.status) ? '待核对' : '指令');
}
function insWhy(r) {
const bits = [];
if (r.qty != null) bits.push('下单 ' + r.qty + ' 股');
if (r.qty != null) bits.push('计划 ' + r.qty + ' 股');
if (r.exec_qty) bits.push('已成交 ' + r.exec_qty + ' 股');
if (r.limit_price) bits.push('限价 ' + r.limit_price);
if (r.reason) bits.push(r.reason);
const last=(r.progress||{}).last_decision||{};
const why=r.reason || ((_LIVE_INS.includes(r.status) && ['waiting','unknown'].includes(r.execution_stage)) ? last.reason : '');
if (why) bits.push(plainCheck(why).replace(/\[实现[AB]\]\s*/g,''));
return bits.join(',');
}
@ -4948,8 +4938,8 @@ createApp({
for (const r of (instructions.value || [])) {
if (_isArch(r) || !_sameDayIns(r)) continue;
const t = _at(r, ['updated_at', 'created_at', 'at', 'dispatched_at']);
out.push({ kind:'order', time:_hm(t), sort:_hms(t), ts_code:r.ts_code,
cat:tx('action', r.action) + ' · ' + tx('insStatus', r.status),
out.push({ kind:'order', badge:insBadge(r), time:_hm(t), sort:_hms(t), ts_code:r.ts_code,
cat:tx('action', r.action) + ' · ' + (r.execution_label || tx('insStatus', r.status)),
strong:true, why:insWhy(r), goLabel:'看在办', go:'ins' });
}
// 3) 待确认提议 —— 自主档位是「只提议」时, 新提议在这里也提醒一次

View File

@ -12,7 +12,7 @@
test_batch45_units.py 父指令总量:回放延迟、部分成交、跨日预留、故障守成与影子模式 (16 例)
test_batch43_units.py 逐票来源核验、实际API至SQL事务、故障回滚与幂等 (14 例)
test_batch42_units.py 提议先准备后采纳、模型复用、并发更新与发布审计 (24 例)
test_batch41_units.py 跨流程买卖互斥、清仓收尾、出口撤单与真实进展及人工清仓T+1 (24 例)
test_batch41_units.py 跨流程买卖互斥、清仓收尾、出口撤单与真实进展及人工清仓T+1 (27 例)
test_batch40_units.py 逐笔历史修复、进度暂停、并发与事务回滚与均价失效 (22 例)
test_batch39_units.py 成交双来源归属、迟到、部分成交与失败守成 (12 例)
test_batch38_units.py 每日计划顺序、版本核验、重新确认、并发采纳、历史保留及采纳失败说明、明确否决撤下 (30 例)

View File

@ -169,6 +169,31 @@ class ConflictsTest(unittest.TestCase):
with patch.object(qmt_repo,'orders_for_parent',side_effect=RuntimeError('unavailable')):
self.assertEqual(c.instruction_progress([row])[0]['execution_label'],'委托状态待核实')
def test_waiting_instruction_is_not_a_sent_order(self):
from app.services import execution_conflicts as c
row=ins(self.fake,'new','OPEN','buy');row['status']='PROPOSED'
row['progress']['last_decision']={'action':'WAIT','reason':'现价31.17高于买入上沿30.02'}
with patch.object(qmt_repo,'orders_for_parent',return_value=[]), patch.object(pms_repo,'update_instruction') as write:
result=c.instruction_progress([row])[0]
self.assertEqual((result['execution_label'],result['execution_stage']),('等待买入条件','waiting'))
self.assertEqual(result['status'],'PROPOSED');write.assert_not_called()
def test_queue_send_and_broker_progress_are_distinct(self):
from app.services import execution_conflicts as c
for status,stage in [('QUEUED','queued'),('SENDING','sending'),('SENT','submitted'),('ACCEPTED','submitted'),('PARTIAL','submitted')]:
row=ins(self.fake,'new','OPEN','buy');row['status']='PROPOSED'
with patch.object(qmt_repo,'orders_for_parent',return_value=[{'status':status}]):
self.assertEqual(c.instruction_progress([row])[0]['execution_stage'],stage)
with patch.object(qmt_repo,'orders_for_parent',side_effect=RuntimeError('offline')):
self.assertEqual(c.instruction_progress([row])[0]['execution_stage'],'unknown')
def test_filled_outbox_waiting_for_ledger_is_not_new_order(self):
from app.services import execution_conflicts as c
row=ins(self.fake,'new','OPEN','buy',600,0)
with patch.object(qmt_repo,'orders_for_parent',return_value=[{'status':'FILLED','cum_qty':600}]):
result=c.instruction_progress([row])[0]
self.assertEqual((result['execution_label'],result['execution_stage']),('成交待入账','reconciling'))
def test_other_stock_not_blocked(self):
from app.services import execution_conflicts as c
ins(self.fake,'exit','EXIT','sell')