增加缠论说明,优化线段中枢

This commit is contained in:
jackyu66git
2026-03-12 17:20:57 +08:00
parent ea47bfe9b7
commit 72196329d1
4 changed files with 79 additions and 4 deletions
+36 -4
View File
@@ -1987,12 +1987,44 @@ class TF_DF():
last_zs.set_end_klc(last_seg.end_bi.end_klc, last_seg.sure_time, 0, last_seg)
last_zs.set_end_seg(last_seg)
# 跳过本组已扫描的线段(从 start_idx 到 cur_idx-1),下一组从 cur_idx 起可能再形成新中枢
start_idx = cur_idx
# 下一组从「裁剪后保留的最后一段」的下一条线段开始,被裁掉的线段会参与下一组 3 根,避免漏到下一中枢
last_kept_idx = cur_idx - 1
for i in range(len(seg_list)):
if seg_list[i] == last_seg:
last_kept_idx = i
break
start_idx = last_kept_idx + 1
continue
else:
# 没有重叠,创建新中枢
# 先确认前一个中枢 - 使用前一个中枢本身的最后一个线段
# 本组3段整体与前中枢不重叠,仍逐根检查:若某线段与 [zd,zg] 重叠(如离开后回抽回到前中枢)则并入扩展,不直接新中枢
added_after_leave = []
for k in range(start_idx, min(start_idx + 3, len(seg_list))):
s = seg_list[k]
if not s.is_sure:
break
sh = max(s.start_bi.high, s.end_bi.high) if s.end_bi else s.start_bi.high
sl = min(s.start_bi.low, s.end_bi.low) if s.end_bi else s.start_bi.low
if sh >= last_zs.zd and sl <= last_zs.zg:
added_after_leave.append(s)
else:
break
if added_after_leave:
segs_for_zs = list(last_zs.seg_list) + list(added_after_leave)
required_end_seg_dir = Chan_SEG_DIR.DOWN if last_zs.dir == Chan_ZS_DIR.DOWN else Chan_SEG_DIR.UP
while len(segs_for_zs) >= 3 and segs_for_zs[-1].dir != required_end_seg_dir:
segs_for_zs.pop()
seg_highs = [s.high for s in segs_for_zs]
seg_lows = [s.low for s in segs_for_zs]
last_zs.set_gg(max(seg_highs))
last_zs.set_dd(min(seg_lows))
last_zs.seg_list = segs_for_zs
last_seg = segs_for_zs[-1]
if last_seg.end_bi:
last_zs.set_end_klc(last_seg.end_bi.end_klc, last_seg.sure_time, 0, last_seg)
last_zs.set_end_seg(last_seg)
start_idx = start_idx + len(added_after_leave)
continue
# 没有任何线段与前中枢重叠,确认前中枢结束并创建新中枢
if last_zs.seg_list and len(last_zs.seg_list) > 0:
prev_zs_last_seg = last_zs.seg_list[-1]
if prev_zs_last_seg.end_bi: