mirror of
https://ghfast.top/https://github.com/aeroxw/easy-tdx.git
synced 2026-09-12 15:44:15 +08:00
chore: add risk disclaimer, CI pipeline, pytest coverage config
- Add risk warning after backtest demo output (survivorship bias, overfitting) - Add disclaimer section at README end - Add slippage comment to backtest demo command - Add CI workflow (test + lint + mypy) for PR/push to main - Add pytest config with coverage threshold (fail_under=50, current=56%)
This commit is contained in:
@@ -0,0 +1,33 @@
|
|||||||
|
name: CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
pull_request:
|
||||||
|
branches: [main]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
python-version: ["3.10", "3.12", "3.13"]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions/setup-python@v5
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python-version }}
|
||||||
|
- run: pip install -e ".[dev]"
|
||||||
|
- run: python -m pytest tests/unit/ -v --tb=short
|
||||||
|
- run: ruff check src/ tests/
|
||||||
|
- run: ruff format --check src/ tests/
|
||||||
|
|
||||||
|
mypy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions/setup-python@v5
|
||||||
|
with:
|
||||||
|
python-version: "3.13"
|
||||||
|
- run: pip install -e ".[dev]"
|
||||||
|
- run: mypy src/
|
||||||
@@ -275,6 +275,7 @@ easy-tdx chanlun SZ 000001 --period 30MIN
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
easy-tdx backtest SZ 300308 --strategy-file strategies/expma_cross.py --count 2000 --cash 1000000 --adjust QFQ --table
|
easy-tdx backtest SZ 300308 --strategy-file strategies/expma_cross.py --count 2000 --cash 1000000 --adjust QFQ --table
|
||||||
|
# 推荐加上 --slippage 0.01 模拟真实滑点(元/股),使回测更贴近实盘
|
||||||
```
|
```
|
||||||
|
|
||||||
输出示例:
|
输出示例:
|
||||||
@@ -289,6 +290,10 @@ easy-tdx backtest SZ 300308 --strategy-file strategies/expma_cross.py --count 20
|
|||||||
交易次数: 24
|
交易次数: 24
|
||||||
```
|
```
|
||||||
|
|
||||||
|
> ⚠️ **回测 ≠ 实盘**。以上收益率为历史数据回测结果,包含幸存者偏差和过拟合风险,
|
||||||
|
> 不构成投资建议。实际交易需考虑滑点、流动性、涨跌停无法成交等因素。
|
||||||
|
> 请在充分理解策略逻辑后谨慎使用。
|
||||||
|
|
||||||
**全策略批量对比(CLI):**
|
**全策略批量对比(CLI):**
|
||||||
|
|
||||||
`easy-tdx run-all` 一行命令跑完 `strategies/` 下所有策略并排名:
|
`easy-tdx run-all` 一行命令跑完 `strategies/` 下所有策略并排名:
|
||||||
@@ -1431,3 +1436,8 @@ ruff format --check src/ tests/ # format check
|
|||||||
- 首个正式版本
|
- 首个正式版本
|
||||||
- TdxClient / AsyncTdxClient 标准协议客户端
|
- TdxClient / AsyncTdxClient 标准协议客户端
|
||||||
- K 线、实时报价、分时、逐笔成交、财务数据
|
- K 线、实时报价、分时、逐笔成交、财务数据
|
||||||
|
|
||||||
|
## 免责声明
|
||||||
|
|
||||||
|
本工具仅供学习和技术研究使用,不构成任何投资建议。使用者应自行承担投资决策的全部风险。
|
||||||
|
作者不对因使用本工具导致的任何直接或间接损失负责。
|
||||||
|
|||||||
@@ -29,3 +29,15 @@ line-length = 100
|
|||||||
|
|
||||||
[tool.ruff.lint]
|
[tool.ruff.lint]
|
||||||
select = ["E", "F", "I", "UP"]
|
select = ["E", "F", "I", "UP"]
|
||||||
|
|
||||||
|
[tool.pytest.ini_options]
|
||||||
|
testpaths = ["tests"]
|
||||||
|
addopts = "--tb=short"
|
||||||
|
|
||||||
|
[tool.coverage.run]
|
||||||
|
source = ["easy_tdx"]
|
||||||
|
omit = ["tests/*"]
|
||||||
|
|
||||||
|
[tool.coverage.report]
|
||||||
|
fail_under = 50
|
||||||
|
show_missing = true
|
||||||
|
|||||||
Reference in New Issue
Block a user