- Revised README.md to enhance clarity on core functionalities and usage instructions. - Updated USAGE.md to reflect the new pipeline script and its parameters. - Modified .gitignore to include additional output files for better management. - Removed outdated output files (all_results.csv, report.md, strong_breakout_up.csv, strong_breakout_down.csv) to streamline data handling. - Improved structure and descriptions in documentation for better user guidance.
106 lines
2.2 KiB
Markdown
106 lines
2.2 KiB
Markdown
# 使用说明
|
||
|
||
## 快速启动
|
||
|
||
```powershell
|
||
.\.venv\Scripts\Activate.ps1
|
||
python scripts/pipeline_converging_triangle.py
|
||
```
|
||
|
||
## 1. 创建与激活虚拟环境
|
||
|
||
```powershell
|
||
# 创建环境(首次)
|
||
python -m venv .venv
|
||
|
||
# 激活环境
|
||
.\.venv\Scripts\Activate.ps1
|
||
```
|
||
|
||
## 2. 安装依赖
|
||
|
||
```powershell
|
||
pip install numpy pandas matplotlib
|
||
```
|
||
|
||
## 3. 运行脚本
|
||
|
||
### 一键流水线(推荐)
|
||
|
||
```powershell
|
||
python scripts/pipeline_converging_triangle.py
|
||
```
|
||
|
||
常用参数:
|
||
|
||
```powershell
|
||
# 指定日期
|
||
python scripts/pipeline_converging_triangle.py --date 20260120
|
||
|
||
# 跳过检测(仅生成报告与图表)
|
||
python scripts/pipeline_converging_triangle.py --skip-detection
|
||
```
|
||
|
||
### 仅批量检测
|
||
|
||
```powershell
|
||
python scripts/run_converging_triangle.py
|
||
```
|
||
|
||
### 仅生成报告
|
||
|
||
```powershell
|
||
python scripts/report_converging_triangles.py
|
||
```
|
||
|
||
### 仅绘制图表
|
||
|
||
```powershell
|
||
python scripts/plot_converging_triangles.py
|
||
```
|
||
|
||
输出(已被 `.gitignore` 忽略,默认不推送远程):
|
||
- `outputs/converging_triangles/all_results.csv`
|
||
- `outputs/converging_triangles/strong_breakout_up.csv`
|
||
- `outputs/converging_triangles/strong_breakout_down.csv`
|
||
- `outputs/converging_triangles/report.md`
|
||
- `outputs/converging_triangles/charts/*.png`
|
||
|
||
## 4. 参数调整
|
||
|
||
编辑 `scripts/triangle_config.py`(统一配置):
|
||
|
||
```python
|
||
DETECTION_PARAMS = ConvergingTriangleParams(
|
||
window=120, # 检测窗口大小
|
||
pivot_k=15, # 枢轴点检测窗口
|
||
shrink_ratio=0.6, # 收敛比阈值(严格模式)
|
||
# ...
|
||
)
|
||
|
||
RECENT_DAYS = 500 # 计算最近 N 天(None=全部历史)
|
||
DISPLAY_WINDOW = 500 # 图表显示范围
|
||
ONLY_VALID = True # 只输出有效三角形
|
||
```
|
||
|
||
## 5. 数据格式
|
||
|
||
数据文件位于 `data/` 目录,格式为 pkl:
|
||
|
||
```python
|
||
{
|
||
'mtx': ndarray (n_stocks, n_days), # 数据矩阵
|
||
'dtes': ndarray (n_days,), # 日期 (20050104)
|
||
'tkrs': ndarray (n_stocks,), # 股票代码 (SH600000)
|
||
'tkrs_name': ndarray (n_stocks,), # 股票名称
|
||
}
|
||
```
|
||
|
||
## 6. 备注
|
||
|
||
- 关闭环境:`deactivate`
|
||
- 权限问题(PowerShell):
|
||
```powershell
|
||
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
|
||
```
|