technical-patterns-lab/docs/突破强度计算方法.md
褚宏光 543572667b Add initial implementation of converging triangle detection algorithm and related documentation
- Created README.md and USAGE.md for project overview and usage instructions.
- Added core algorithm in src/converging_triangle.py for batch processing of stock data.
- Introduced data files (open.pkl, high.pkl, low.pkl, close.pkl, volume.pkl) for OHLCV data.
- Developed output documentation for results and breakout strength calculations.
- Implemented scripts for running the detection and generating reports.
- Added SVG visualizations and markdown documentation for algorithm details and usage examples.
2026-01-21 18:02:58 +08:00

188 lines
4.0 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.

# 突破强度计算方法
## 概述
突破强度是一个 **0~1** 的连续分数,用于衡量收敛三角形突破的有效性。
分数越高,表示突破越强势、越可信。
---
## 计算公式
```python
strength = price_score × 5 × (1 + convergence_bonus × 0.5) × (1 + vol_bonus × 0.5)
```
最终结果限制在 `[0, 1]` 范围内。
---
## 三个影响因素
### 1. 价格突破幅度 (price_score)
衡量收盘价突破趋势线的程度。
```python
# 向上突破
price_up = max(0, (close - upper_line) / upper_line)
# 向下突破
price_down = max(0, (lower_line - close) / lower_line)
```
| 突破幅度 | price_score |
|----------|-------------|
| 未突破 | 0 |
| 突破 1% | 0.01 |
| 突破 5% | 0.05 |
| 突破 10% | 0.10 |
---
### 2. 收敛加成 (convergence_bonus)
三角形收敛程度越高,突破越有效。
```python
convergence_bonus = max(0, 1 - width_ratio)
```
| width_ratio | 收敛程度 | convergence_bonus |
|-------------|----------|-------------------|
| 0.8 | 较弱 | 0.2 |
| 0.5 | 中等 | 0.5 |
| 0.2 | 很强 | 0.8 |
| 0.1 | 极强 | 0.9 |
**width_ratio** = 三角形末端宽度 / 起始宽度
---
### 3. 成交量加成 (vol_bonus)
放量突破更可信。
```python
vol_bonus = min(1, max(0, volume_ratio - 1))
```
| volume_ratio | 成交量状态 | vol_bonus |
|--------------|------------|-----------|
| 0.8 | 缩量 | 0 |
| 1.0 | 平量 | 0 |
| 1.5 | 放量 50% | 0.5 |
| 2.0 | 放量 100% | 1.0 (满分) |
| 3.0 | 放量 200% | 1.0 (上限) |
**volume_ratio** = 当日成交量 / 近 N 日均量
---
## 加权系数说明
```python
strength = price_score × 5 × (1 + convergence_bonus × 0.5) × (1 + vol_bonus × 0.5)
```
| 系数 | 作用 |
|------|------|
| `× 5` | 放大价格突破分数,使 2% 突破 = 0.1 基础分 |
| `× (1 + convergence_bonus × 0.5)` | 收敛加成最多增加 50% |
| `× (1 + vol_bonus × 0.5)` | 成交量加成最多增加 50% |
---
## 计算示例
### 示例 1强势突破
```
输入:
close = 10.5, upper_line = 10.0 (突破 5%)
width_ratio = 0.2 (收敛很强)
volume_ratio = 1.8 (放量 80%)
计算:
price_up = (10.5 - 10.0) / 10.0 = 0.05
convergence_bonus = 1 - 0.2 = 0.8
vol_bonus = min(1, 1.8 - 1) = 0.8
strength_up = 0.05 × 5 × (1 + 0.8 × 0.5) × (1 + 0.8 × 0.5)
= 0.25 × 1.4 × 1.4
= 0.49
结果: 向上突破强度 = 0.49 (中度突破)
```
### 示例 2弱势突破
```
输入:
close = 10.1, upper_line = 10.0 (突破 1%)
width_ratio = 0.7 (收敛较弱)
volume_ratio = 0.9 (缩量)
计算:
price_up = 0.01
convergence_bonus = 0.3
vol_bonus = 0
strength_up = 0.01 × 5 × (1 + 0.3 × 0.5) × (1 + 0)
= 0.05 × 1.15 × 1.0
= 0.0575
结果: 向上突破强度 = 0.06 (微弱突破)
```
### 示例 3极强突破
```
输入:
close = 11.0, upper_line = 10.0 (突破 10%)
width_ratio = 0.15 (极度收敛)
volume_ratio = 2.5 (放量 150%)
计算:
price_up = 0.10
convergence_bonus = 0.85
vol_bonus = 1.0
strength_up = 0.10 × 5 × (1 + 0.85 × 0.5) × (1 + 1.0 × 0.5)
= 0.50 × 1.425 × 1.5
= 1.07 → 截断为 1.0
结果: 向上突破强度 = 1.0 (满分)
```
---
## 强度等级参考
| 强度范围 | 等级 | 含义 |
|----------|------|------|
| 0 ~ 0.1 | 无/微弱 | 未突破或假突破风险高 |
| 0.1 ~ 0.3 | 轻度 | 有突破迹象,需观察确认 |
| 0.3 ~ 0.6 | 中度 | 有效突破,可作为参考信号 |
| 0.6 ~ 1.0 | 强势 | 高置信度突破,值得关注 |
---
## 代码位置
```
src/converging_triangle.py
├── calc_breakout_strength() # 突破强度计算函数
└── detect_converging_triangle() # 调用位置
```
---
## 相关参数
| 参数 | 默认值 | 说明 |
|------|--------|------|
| `vol_window` | 20 | 计算成交量均值的窗口大小 |
| `vol_k` | 1.3 | 成交量确认阈值volume_confirmed 判断用) |
| `break_tol` | 0.001 | 突破判定容差 |