technical-patterns-lab/discuss/20260128-讨论.md
褚宏光 09ac66caa1 Enhance converging triangle detection with new features and performance improvements
- Added support for daily best stocks reporting, including a new CSV output for daily best triangles based on strength.
- Introduced a logging mechanism to capture detailed execution logs, improving traceability and debugging.
- Implemented a v2 optimization for batch detection, significantly reducing detection time from 92 seconds to under 2 seconds.
- Updated the .gitignore file to include new log files and outputs for better management.
- Enhanced the pipeline script to allow for flexible configuration of detection parameters and improved user experience.

Files modified:
- scripts/run_converging_triangle.py: Added logging and v2 optimization.
- scripts/pipeline_converging_triangle.py: Updated for new features and logging.
- scripts/plot_converging_triangles.py: Adjusted for new plotting options.
- New files: discuss/20260127-拟合线.md, discuss/20260128-拟合线.md, and several images for visual documentation.
2026-01-28 18:43:46 +08:00

87 lines
3.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 上/下沿线,有些点没有碰到线的边缘
![](images/2026-01-28-11-16-46.png)
![](images/2026-01-28-11-16-56.png)
## 问题
视觉上看图时,上沿/下沿线与收盘价曲线偏离明显,部分连接枢轴点看起来距离真实收盘价点较远。
## 原因
- 枢轴点与边界拟合使用的是 High/Low高低价而主图只绘制了收盘价曲线出现长上影/下影时会放大偏离感。
- 采用“锚点+覆盖率”的边界拟合法,目标是包络多数枢轴点而非贴合收盘价,因此线会更保守、更远离收盘价。
## 解决方案
![](images/2026-01-28-15-56-12.png)
已在绘图脚本加入仅影响展示的两类开关(不改变检测结果):
- 显示日内高低价范围,让边界线与高低价的关系更直观:`--show-high-low`
- 绘图时将边界线拟合源切换为收盘价以改善视觉贴合:`--plot-boundary-source close`
示例:
- `python scripts/plot_converging_triangles.py --show-high-low`
- `python scripts/plot_converging_triangles.py --plot-boundary-source close`
## 后续发现的问题(已修复)
### 问题1拟合贴合度显示为0
**现象**:使用 `--plot-boundary-source close` 时,图表标题中的拟合贴合度显示为 0.000
**原因**
- 检测算法始终使用高低价计算拟合贴合度
- 绘图时使用收盘价拟合边界线
- 两者数据源不一致,导致显示的贴合度与实际的拟合线不匹配
**修复**
- 在绘图脚本中,当使用收盘价拟合时,重新基于收盘价和实际拟合线计算贴合度
- 在标题中明确标注使用的是"拟合贴合度(收盘价)"还是"拟合贴合度(高低价)"
### 问题2枢轴点显示位置不匹配
**现象**:使用 `--plot-boundary-source close` 时,详细模式下的枢轴点标记仍然显示在高低价位置,而不是收盘价位置
**原因**
- 枢轴点标记的Y坐标始终使用 `high_win[ph_idx]``low_win[pl_idx]`
- 即使拟合线使用收盘价,标记位置仍基于高低价
**修复**
- 根据 `plot_boundary_source` 参数选择枢轴点标记的Y坐标
- 使用收盘价拟合时,枢轴点标记也显示在收盘价位置
### 问题3流水线脚本缺少参数支持
**现象**`pipeline_converging_triangle.py` 无法传递 `--plot-boundary-source` 参数给绘图脚本
**修复**
-`pipeline_converging_triangle.py` 中添加 `--plot-boundary-source` 参数
- 将参数传递给 `plot_converging_triangles.py`
- 在流水线开始时显示当前使用的边界线拟合数据源
## 使用说明
### 单独绘图
```bash
# 使用收盘价拟合边界线
python scripts/plot_converging_triangles.py --plot-boundary-source close
# 显示高低价范围
python scripts/plot_converging_triangles.py --show-high-low
# 组合使用
python scripts/plot_converging_triangles.py --plot-boundary-source close --show-high-low
```
### 流水线处理
```bash
# 使用收盘价拟合边界线处理所有股票
python scripts/pipeline_converging_triangle.py --clean --all-stocks --plot-boundary-source close
```
## 注意事项
- `--plot-boundary-source` 参数仅影响绘图展示,**不改变检测算法的结果**
- 检测算法始终使用高低价进行枢轴点检测和边界拟合
- 使用收盘价拟合时,显示的拟合贴合度会重新计算,以匹配实际显示的拟合线
- 强度分中的其他部分(价格、收敛、成交量、边界利用率)仍基于检测算法的结果
# 批量检测算法优化
![](images/2026-01-28-17-13-37.png)
![](images/2026-01-28-17-22-42.png)
原来92秒
现在:< 2秒首次需要3-5秒编译
提升50倍以上 🚀