technical-patterns-lab/docs/file-naming-fix.md
褚宏光 22582851a1 Enhance converging triangle detection with new features and documentation updates
- Introduced an interactive HTML stock viewer for visualizing strength scores and filtering stocks based on user-defined thresholds.
- Added `--all-stocks` parameter to generate charts for all 108 stocks, including those not meeting convergence criteria.
- Implemented a new scoring system for breakout strength, incorporating fitting adherence to improve accuracy.
- Updated multiple documentation files, including usage instructions and feature overviews, to reflect recent enhancements.
- Improved error handling and file naming conventions to ensure compatibility across platforms.
2026-01-27 16:17:28 +08:00

134 lines
3.7 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.

# 文件命名特殊字符修复
> 修复时间2026-01-27
> 版本v1.1
## 问题描述
在使用 `--all-stocks` 参数生成所有股票图表时发现只生成了101张图而不是预期的108张。
经排查发现有7只股票被跳过原因包括
1. **文件名包含非法字符**4只ST股票
2. **数据缺失**5只停牌/退市股票)
## 问题详情
### Windows文件名非法字符
Windows操作系统不允许文件名中包含以下字符
```
* ? " < > | : / \
```
部分ST股票的名称包含 `*` 字符,导致文件创建失败:
- `*ST国讯` → 文件名 `20260120_SH600898_*ST国讯.png` 非法
- `*ST原尚` → 文件名 `20260120_SH603813_*ST原尚.png` 非法
- `*ST猛狮` → 文件名 `20260120_SZ000535_*ST猛狮.png` 非法
- `*ST东通` → 文件名 `20260120_SZ300379_*ST东通.png` 非法
## 修复方案
`scripts/plot_converging_triangles.py` 中添加文件名清理逻辑:
```python
# 清理文件名中的非法字符Windows文件名不允许: * ? " < > | : / \
stock_name_clean = (stock_name
.replace('*', '')
.replace('?', '')
.replace('"', '')
.replace('<', '')
.replace('>', '')
.replace('|', '')
.replace(':', '')
.replace('/', '')
.replace('\\', ''))
output_filename = f"{target_date}_{stock_code}_{stock_name_clean}{suffix}.png"
```
## 修复结果
### 修复前
- **生成图表**101张
- **跳过股票**7只
- 4只因文件名非法
- 5只因数据缺失有重叠
### 修复后
- **生成图表**103张
- **跳过股票**5只仅因数据缺失
### 成功修复的股票
1.**SH603813** *ST原尚 → `20260120_SH603813_ST原尚.png`
2.**SZ300379** *ST东通 → `20260120_SZ300379_ST东通.png`
### 仍然跳过的股票(正常,因数据缺失)
1.**SH600898** *ST国讯 - 20260120停牌/退市
2.**SZ000535** *ST猛狮 - 20260120停牌/退市
3.**SZ000662** 索芙特 - 20260120停牌/退市
4.**SZ000866** 扬子石化 - 20260120停牌/退市
5.**SZ300178** 腾邦集团(退市) - 20260120停牌/退市
## 文件名示例
### 修复前(失败)
```
20260120_SH603813_*ST原尚.png ❌ 包含*字符
20260120_SZ300379_*ST东通.png ❌ 包含*字符
```
### 修复后(成功)
```
20260120_SH603813_ST原尚.png ✅ 移除*字符
20260120_SZ300379_ST东通.png ✅ 移除*字符
```
## 覆盖率统计
| 项目 | 数量 | 百分比 |
|------|------|--------|
| 股票池总数 | 108 | 100% |
| 成功生成图表 | 103 | 95.4% |
| 数据缺失跳过 | 5 | 4.6% |
## 技术说明
### 为什么不是108张全部生成
**合理原因**这5只股票在20260120当天确实没有交易数据
- 停牌中
- 已退市
- 暂停上市
**处理方式**:代码正确地检测到数据缺失并跳过这些股票,这是预期行为。
### 跨平台兼容性
修复后的代码在以下系统均可正常运行:
- ✅ Windows主要修复目标
- ✅ Linux本身就支持*字符,但统一清理更安全)
- ✅ macOS本身就支持*字符,但统一清理更安全)
## 相关文件
- 修复代码:`scripts/plot_converging_triangles.py` (第497行)
- 使用说明:`USAGE.md`
- 功能文档:`docs/all-stocks-feature.md`
## 测试验证
```powershell
# 重新生成所有股票图表
python scripts/pipeline_converging_triangle.py --date 20260120 --all-stocks
# 检查生成结果
ls outputs/converging_triangles/charts/ | grep "20260120" | grep -v "_detail" | wc -l
# 输出103预期值
```
## 总结
✅ 问题已完全修复现在可以正常为所有有数据的股票包括ST股生成图表。
**最终覆盖率**103/103 有数据的股票 = **100%**