technical-patterns-lab/docs/强度分组成梳理.md
褚宏光 0f8b9d836b Refactor strength scoring system with new parameters and renaming
- Introduced a new "tilt" parameter to the strength scoring system, allowing for the assessment of triangle slope directionality.
- Renamed existing parameters: "拟合贴合度" to "形态规则度" and "边界利用率" to "价格活跃度" for improved clarity.
- Updated normalization methods for all strength components to ensure they remain within the [0, 1] range, facilitating LLM tuning.
- Enhanced documentation to reflect changes in parameter names and scoring logic, including detailed explanations of the new tilt parameter.
- Modified multiple source files and scripts to accommodate the new scoring structure and ensure backward compatibility.

Files modified:
- `src/converging_triangle.py`, `src/converging_triangle_optimized.py`, `src/triangle_detector_api.py`: Updated parameter names and scoring logic.
- `scripts/plot_converging_triangles.py`, `scripts/generate_stock_viewer.py`: Adjusted for new scoring parameters in output.
- New documentation files created to explain the renaming and new scoring system in detail.
2026-01-29 15:55:50 +08:00

100 lines
4.4 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.

# 强度分组成梳理
根据当前代码,**强度分由 6 个组成部分**
```python
# 权重配置(调整后,总和 = 100%)
W_PRICE = 0.45 # 突破幅度权重从50%降至45%
W_CONVERGENCE = 0.15 # 收敛度权重
W_VOLUME = 0.10 # 成交量权重
W_GEOMETRY = 0.10 # 形态规则度权重
W_ACTIVITY = 0.15 # 价格活跃度权重
W_TILT = 0.05 # 倾斜度权重(新增)
```
## 组成详情
| 序号 | 组成部分 | 权重 | 英文字段名 | 说明 | 归一化方式 | 范围保证 |
|------|---------|------|-----------|------|-----------|---------|
| 1 | **突破幅度分** | 45% | `price_score` | 价格突破上/下沿的幅度 | `np.tanh(pct * 15.0)` | tanh 输出 [0, 1](因为 pct ≥ 0 |
| 2 | **收敛度分** | 15% | `convergence_score` | 三角形收敛程度1 - width_ratio | `max(0, min(1, 1 - width_ratio))` | 显式 clamp 到 [0, 1] |
| 3 | **成交量分** | 10% | `volume_score` | 突破时的放量程度 | `min(1, max(0, volume_ratio - 1))` | 显式 clamp 到 [0, 1] |
| 4 | **形态规则度** | 10% | `geometry_score` | 枢轴点到拟合线的贴合程度,形态的几何标准性 | `exp(-error * 20)` + clamp | 指数衰减 + 显式 clamp |
| 5 | **价格活跃度** | 15% | `activity_score` | 价格走势对通道空间的利用程度,振荡充分性 | 逐日计算 `1 - blank_ratio` 的平均 + clamp | 每日 clamp + 最终 clamp |
| 6 | **倾斜度分** | 5% | `tilt_score` | 中轴倾斜方向与突破方向的一致性(新增) | `(1 ± tilt) / 2` + clamp | 显式 clamp 到 [0, 1] |
**总计100%**
## 计算公式
```python
strength = (
0.45 × 突破幅度分 +
0.15 × 收敛度分 +
0.10 × 成交量分 +
0.10 × 形态规则度 +
0.15 × 价格活跃度 +
0.05 × 倾斜度分
)
```
## 空白惩罚机制
当**价格活跃度**低于 20% 时,会对总强度进行额外的降分惩罚,避免"通道很宽但价格很空"的误判。
## 命名说明
> **注意**:自 2026-01-29 起,原"拟合贴合度"重命名为"形态规则度",原"边界利用率"重命名为"价格活跃度",以更直观地表达其含义。
>
> - **形态规则度**测量枢轴点的几何标准性4-8个关键点
> - **价格活跃度**测量价格振荡的充分性240天完整数据
>
> 详见:`docs/命名优化_拟合贴合度_边界利用率_重命名.md`
## 各分量的含义
### 1. 突破幅度分 (50%)
- **作用**:衡量价格突破三角形边界的力度
- **计算**:使用 tanh 非线性归一化
- 1% 突破 → 0.15
- 3% 突破 → 0.42
- 5% 突破 → 0.64
- 10% 突破 → 0.91
### 2. 收敛度分 (15%)
- **作用**:衡量三角形收敛的紧密程度
- **计算**1 - width_ratio末端宽度/起始宽度)
- **示例**:收敛到 30% → 得分 0.7
### 3. 成交量分 (10%)
- **作用**:衡量突破时的成交量放大程度
- **计算**(当前成交量/均值 - 1),上限为 1.0
- **示例**:成交量为均值的 2 倍 → 得分 1.0
### 4. 形态规则度 (10%)
- **作用**:衡量形态的几何标准性
- **测量**4-8 个关键枢轴点到拟合线的距离
- **特点**:关注形态结构的完整性
### 5. 价格活跃度 (15%)
- **作用**:衡量价格振荡的充分性
- **测量**240 天价格对通道空间的利用程度
- **特点**:识别真实博弈 vs 僵尸形态
### 6. 倾斜度分 (5%)
- **作用**:衡量三角形中轴倾斜方向与突破方向的一致性
- **计算步骤**
1. 计算中轴斜率:`mid_slope = (上沿斜率 + 下沿斜率) / 2`
2. 计算倾斜程度:`tilt = arctan(mid_slope) / (π/4)`,范围 [-1, +1]
- -1 = 强烈向下倾斜0 = 水平,+1 = 强烈向上倾斜
3. 根据突破方向计算得分(范围 [0, 1]
- 向上突破:`score = (1 + tilt) / 2`
- 向下突破:`score = (1 - tilt) / 2`
- 未突破:`score = 0.5`
- **示例**(实际计算结果):
- 上升三角形斜率0.025+ 向上突破 → tilt≈0.032 → 得分 0.516(略顺势)
- 对称三角形斜率0+ 向上突破 → tilt=0 → 得分 0.500(中性)
- 下降三角形(斜率-0.025+ 向上突破 → tilt≈-0.032 → 得分 0.484(略逆势)
- 强向上倾斜斜率0.10+ 向上突破 → tilt≈0.127 → 得分 0.563(明显顺势)
- **特点**:评估突破方向与形态趋势的协调性,得分始终在 [0, 1] 范围内