diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..6649cce --- /dev/null +++ b/.github/workflows/ci.yml @@ -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/ diff --git a/README.md b/README.md index 9bc83e8..9f38e2f 100644 --- a/README.md +++ b/README.md @@ -275,6 +275,7 @@ easy-tdx chanlun SZ 000001 --period 30MIN ```bash 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 ``` +> ⚠️ **回测 ≠ 实盘**。以上收益率为历史数据回测结果,包含幸存者偏差和过拟合风险, +> 不构成投资建议。实际交易需考虑滑点、流动性、涨跌停无法成交等因素。 +> 请在充分理解策略逻辑后谨慎使用。 + **全策略批量对比(CLI):** `easy-tdx run-all` 一行命令跑完 `strategies/` 下所有策略并排名: @@ -1431,3 +1436,8 @@ ruff format --check src/ tests/ # format check - 首个正式版本 - TdxClient / AsyncTdxClient 标准协议客户端 - K 线、实时报价、分时、逐笔成交、财务数据 + +## 免责声明 + +本工具仅供学习和技术研究使用,不构成任何投资建议。使用者应自行承担投资决策的全部风险。 +作者不对因使用本工具导致的任何直接或间接损失负责。 diff --git a/pyproject.toml b/pyproject.toml index 6779c0c..44c33a5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,3 +29,15 @@ line-length = 100 [tool.ruff.lint] 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