Tortoise/strategy/doc/strategy1_a500_close_chart.md
2026-06-23 10:57:20 +08:00

50 lines
1.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.

# 策略1中证 A500 成立以来收盘价图
## 目标
`sidecar` 模块获取中证 A500 指数日线数据,将指数自成立日至今日的收盘价绘制为一张 SVG 折线图。
## 假设
- 指数名称:中证 A500 指数。
- 指数代码:`sh000510`。
- 成立起始日:`2024-09-23`。
- 数据周期:日线。
- K 线数据源:`sidecar.sources.tencent.TencentFinanceSource`。
- 输出格式SVG 图片,默认路径为 `strategy/output/a500_close.svg`
## 数据源说明
策略通过 `sidecar` 的统一服务读取和缓存数据,但 K 线源显式使用腾讯财经。原因是当前 mootdx 对 `sh000510` 返回的日线价格量级异常,腾讯财经快照和 K 线价格量级一致,更适合绘制中证 A500 指数历史走势。
## 运行方式
```powershell
python -m strategy.a500_close_chart --refresh
```
可指定输出路径:
```powershell
python -m strategy.a500_close_chart --output strategy/output/a500_close.svg --refresh
```
## 输入
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| `--output` | string | `strategy/output/a500_close.svg` | 输出 SVG 文件路径 |
| `--refresh` | bool | `False` | 是否强制刷新 sidecar 缓存 |
## 输出
生成一张 SVG 图片:
- 横轴:交易日期,范围为中证 A500 成立日 `2024-09-23` 至当前可获取的最新交易日。
- 纵轴:日收盘价。
- 标题:`中证 A500 指数成立以来收盘价`。
## 测试用例
- `4-1`:过滤成立日之前的数据,并忽略空收盘价。
- `4-2`:根据收盘价点生成包含标题、日期和折线的 SVG。