判定证据按信号类型分型展示:ignition/scan_bd输出evidence_items(各条件实测值+ok);详情接口实时重算透传;客户端详情页按kind渲染证据卡(背离=堆表/起爆=四条件表/BD=共振证据表)

This commit is contained in:
2026-11-22 14:25:40 +08:00
parent 3fe5e7c470
commit f271287d38
6 changed files with 107 additions and 8 deletions
@@ -20,6 +20,7 @@ class SignalDetail {
final double afterHigh, prevHigh, afterArea, prevArea;
final String kind;
final bool verified;
final List<Map<String, dynamic>> evidenceItems;
const SignalDetail({
required this.id,
@@ -29,6 +30,7 @@ class SignalDetail {
required this.divergenceTime,
required this.path,
required this.kind,
this.evidenceItems = const [],
required this.triggerClose,
required this.heapLen,
required this.prevHeapLen,
@@ -47,6 +49,9 @@ class SignalDetail {
divergenceTime: (m['divergence_time'] ?? '') as String,
path: (m['path'] ?? '') as String,
kind: (m['kind'] ?? 'divergence') as String,
evidenceItems: ((m['evidence_items'] as List?) ?? const [])
.map((e) => Map<String, dynamic>.from(e as Map))
.toList(),
triggerClose: (m['trigger_close'] as num?)?.toDouble() ?? 0,
heapLen: (m['heap_len'] as num?)?.toInt() ?? 0,
prevHeapLen: (m['prev_heap_len'] as num?)?.toInt() ?? 0,
@@ -264,7 +269,54 @@ class _SignalDetailPageState extends ConsumerState<SignalDetailPage> {
}
Widget _evidence(SignalDetail s) {
String fmtA(double v) => v.toStringAsFixed(1).replaceAllMapped(RegExp(r'\B(?=(\d{3})+(?!\d))'), (m) => ',');
// 起爆点 / BD共振:渲染后端实时计算的判定证据列表
if (s.isIgnition || s.kind == 'bd_resonance') {
final items = s.evidenceItems;
if (items.isEmpty) {
return const Card(
color: XlColors.surface,
child: Padding(
padding: EdgeInsets.all(14),
child: Text('该信号的判定证据生成中(历史数据)', style: TextStyle(fontSize: 13, color: XlColors.clay)),
),
);
}
return Card(
color: XlColors.surface,
child: Padding(
padding: const EdgeInsets.all(14),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
for (final e in items)
Padding(
padding: const EdgeInsets.symmetric(vertical: 4),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Icon(
e['ok'] == true ? Icons.check_circle : Icons.cancel,
size: 16,
color: e['ok'] == true ? const Color(0xFF00C853) : XlColors.clay,
),
const SizedBox(width: 8),
Expanded(
child: Text(
'${e['label']}:${e['value']}',
style: const TextStyle(fontSize: 13, color: XlColors.porcelain, height: 1.5),
),
),
],
),
),
],
),
),
);
}
String fmtA(double v) => v >= 1000000
? (v / 1000000).toStringAsFixed(1) + 'M'
: v.toStringAsFixed(v % 1 == 0 ? 0 : 1);
String fmtH(double v) =>
v >= 10000 ? v.toStringAsFixed(0) : v.toStringAsFixed(v % 1 == 0 ? 0 : 1);
return Container(
+1 -1
View File
@@ -14,7 +14,7 @@ import 'package:path_provider/path_provider.dart';
import '../../core/network/api_client.dart';
import '../../core/theme/app_colors.dart';
const kAppVersion = '1.2.0'; // 与 pubspec.yaml version 同步
const kAppVersion = '1.3.0'; // 与 pubspec.yaml version 同步
/// 比较语义化版本:a < b 返回 -1,> 返回 1,相等 0
int compareVersion(String a, String b) {
+34 -2
View File
@@ -199,6 +199,25 @@ def scan(bars: Sequence[dict], ind: dict | None = None, upto: str | None = None)
)
seg_start_short = [bear_align[i] and not (bear_align[i - 1] if i >= 1 else False) for i in range(m)]
def _long_evidence(i: int) -> list[dict]:
return [
{"label": "MA14 / MA92", "value": f"{ma14[i]:.1f} / {ma92[i]:.1f}"},
{"label": "收盘站上两均线", "value": "√" if c[i] > ma14[i] and c[i] > ma92[i] else "✗", "ok": bool(c[i] > ma14[i] and c[i] > ma92[i])},
{"label": "近3根·突破上轨次数", "value": str(_count(break_upper, i, NW)), "ok": _count(break_upper, i, NW) >= 1},
{"label": "近3根·MACD金叉红K次数", "value": str(_count(macd_gold_red, i, NW)), "ok": _count(macd_gold_red, i, NW) >= 1},
{"label": "近3根·第一根粉柱次数", "value": str(_count(first_pink, i, NW)), "ok": _count(first_pink, i, NW) >= 1},
{"label": "庄家弱势区", "value": "是(排除)" if weak_zone[i] else "否", "ok": not weak_zone[i]},
]
def _short_evidence(i: int) -> list[dict]:
return [
{"label": "MA14 / MA92", "value": f"{ma14[i]:.1f} / {ma92[i]:.1f}"},
{"label": "空头排列", "value": "√", "ok": bool(ma92[i] is not None and ma14[i] is not None and ma92[i] > ma14[i])},
{"label": "近3根·跌破下轨次数", "value": str(_count(break_lower, i, NW)), "ok": _count(break_lower, i, NW) >= 1},
{"label": "近3根·MACD死叉次数", "value": str(_count(macd_dead, i, NW)), "ok": _count(macd_dead, i, NW) >= 1},
{"label": "近3根·第一根绿柱次数", "value": str(_count(first_green, i, NW)), "ok": _count(first_green, i, NW) >= 1},
]
out: list[dict] = []
for i in range(1, m):
# 做多:波段去重——本段(自段起点起)此前未出现过条件组
@@ -210,7 +229,7 @@ def scan(bars: Sequence[dict], ind: dict | None = None, upto: str | None = None)
for k in range(max(1, i - window + 1), i + 1)
)
if not prior:
out.append(_sig(bars, i, "long"))
out.append({**_sig(bars, i, "long"), "evidence_items": _long_evidence(i)})
if short_set[i]:
d = _barslast(seg_start_short, i)
window = (d if d is not None else i) + 1
@@ -219,7 +238,7 @@ def scan(bars: Sequence[dict], ind: dict | None = None, upto: str | None = None)
for k in range(max(1, i - window + 1), i + 1)
)
if not prior:
out.append(_sig(bars, i, "short"))
out.append({**_sig(bars, i, "short"), "evidence_items": _short_evidence(i)})
if upto is not None:
out = [s for s in out if s["dt"] > upto]
@@ -310,7 +329,19 @@ def scan_bd(bars: Sequence[dict], ind: dict | None = None) -> list[dict]:
cond_b = up[i] and any(dn[i - k] for k in (1, 2, 3) if i - k >= 0)
if not (cond_a or cond_b):
continue
center = (o[i] + c[i]) / 2
body_top = max(o[i], c[i])
bar = bars[i]
ev = [
{"label": "MACD(12/26) 死叉", "value": "√", "ok": True},
{"label": "近3根内曾在DEA上方", "value": "√", "ok": True},
{"label": "第4根前 DIFF≤DEA", "value": "√", "ok": True},
{"label": "实体重心 ≥ 布林中轨", "value": f"重心 {center:.1f} / 中轨 {mid[i]:.1f}", "ok": bool(center >= mid[i])},
{"label": "实体顶 ≤ 布林上轨", "value": f"{body_top:.1f} / {upper[i]:.1f}", "ok": bool(body_top <= upper[i])},
{"label": "COND_A 量能绿翻红", "value": "√" if cond_a else "✗", "ok": cond_a},
{"label": "COND_B 庄家AA翻多", "value": "√" if cond_b else "✗", "ok": cond_b},
{"label": "AA / MA35", "value": f"{aa[i]:.1f} / {ma35[i]:.1f}"},
]
out.append(
{
"dt": bar["dt"],
@@ -319,6 +350,7 @@ def scan_bd(bars: Sequence[dict], ind: dict | None = None) -> list[dict]:
"close": bar["c"],
"path": "bd",
"kind": "bd_resonance",
"evidence_items": ev,
}
)
return out
+16 -1
View File
@@ -18,6 +18,7 @@ from ..algo.lx94 import indicators as calc_indicators
from ..deps import current_user
from ..db import query
from ..errors import BizError, MARKET_UNAVAILABLE, SYMBOL_INSUFFICIENT, SYMBOL_NO_DATA, ok
from ..algo import ignition
from ..algo.ignition import boll
from ..market import service
@@ -265,4 +266,18 @@ def signal_detail(signal_id: int, user: dict = Depends(current_user)):
rows = query("SELECT * FROM signals WHERE id=?", (signal_id,))
if not rows:
raise BizError(SYMBOL_NO_DATA, "信号记录不可用")
return ok(_clean_signal(rows[0]))
d = _clean_signal(rows[0])
kind = d.get("kind", "divergence")
if kind in ("long_ignition", "short_ignition", "bd_resonance"):
# 起爆点/BD共振:实时重算判定证据(与扫描器同一算法)
try:
bars = service.load_cached(d["symbol"], d["interval"]) or service.refresh(d["symbol"], rows[0]["market"] if "market" in d else 0, d["interval"])
if bars:
ind = _indicators_cached(d["symbol"], d["interval"], bars)
sigs = ignition.scan(bars, ind) if kind != "bd_resonance" else ignition.scan_bd(bars, ind)
ev = next((x for x in sigs if x["dt"] == d["divergence_time"]), None)
if ev:
d["evidence_items"] = ev.get("evidence_items", [])
except Exception:
pass # 证据获取失败不影响详情主内容
return ok(d)
+3 -3
View File
@@ -1,8 +1,8 @@
{
"latest_version": "1.3.0",
"min_version": "",
"notes": "蒙版升级验证:三信号+90/120分钟",
"min_version": "1.1.2",
"notes": "新IP",
"filename": "xuanlong-1.3.0.apk",
"size": 58878766,
"uploaded_at": "2026-11-22 12:14:15"
"uploaded_at": "2026-11-22 14:16:17"
}
Binary file not shown.