Tortoise/README.md
2026-06-24 16:50:59 +08:00

50 lines
1.5 KiB
Markdown
Raw Permalink 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.

# Tortoise Stock
轻量级 A 股投研回测系统。当前已提供 Python sidecar 的统一数据获取与 DuckDB 本地缓存接口,后续策略模块可直接基于该接口读取 K 线与行情快照。
## Python sidecar
安装依赖:
```bash
pip install -e .[test]
```
启动服务:
```bash
uvicorn sidecar.api:app --host 127.0.0.1 --port 8765
```
常用接口:
- `GET /health`:健康检查。
- `GET /kline/{symbol}?period=day&limit=800&refresh=false`:获取 K 线,日/周/月优先腾讯财经,失败后回退 mootdx分钟线使用 mootdx并写入 DuckDB。
- `GET /snapshot/{symbol}?refresh=false`:获取实时快照,优先腾讯财经,失败后回退 mootdx并写入 DuckDB TTL 缓存。
默认 DuckDB 文件为 `data/tortoise.duckdb`,可通过 `TORTOISE_DUCKDB_PATH` 修改。
## 策略1中证 A500 收盘价图
运行:
```powershell
python -m strategy.a500_close_chart --refresh
```
默认输出:`strategy/output/a500_close_chart/a500_close.svg`。
## 策略2中证 A500 与沪深 300 双轴收盘价图
运行:
```powershell
python -m strategy.a500_hs300_close_chart --refresh
```
默认输出:`strategy/output/a500_hs300_close_chart/a500_hs300_close.svg`。
## 策略通用工具
- 所有策略默认输出到 `strategy/output/<策略模块名>/`,图片和 md 说明文件放在同一个策略子目录。
- `strategy.indicators` 提供 `calculate_ma`、`calculate_ema`、`calculate_macd`、`calculate_kdj`用于均线、MACD 与 KDJ 计算。