mirror of
https://ghfast.top/https://github.com/aeroxw/easy_tdx_max.git
synced 2026-09-12 20:24:19 +08:00
feat(backtest): add CLI command with auto data fetch and table output
- Created src/easy_tdx/backtest/cli.py with backtest command - Supports --strategy-file to load Python strategy classes - Supports --indicators to precompute technical indicators - Supports --cash, --commission, --execution, --period, --adjust, --count options - Supports json/table/csv output formats - Auto-loads K-line data via get_mac_client() - Registered backtest command in src/easy_tdx/cli/__init__.py - Added tests/unit/test_backtest_cli.py with basic CLI tests Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
706f22ba5e
commit
fc0777533e
@@ -0,0 +1,30 @@
|
||||
"""回测 CLI 命令测试。"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from click.testing import CliRunner
|
||||
|
||||
|
||||
class TestBacktestCLI:
|
||||
"""测试回测 CLI 命令。"""
|
||||
|
||||
def test_help(self):
|
||||
"""测试 --help 显示帮助。"""
|
||||
from easy_tdx.backtest.cli import backtest
|
||||
|
||||
runner = CliRunner()
|
||||
result = runner.invoke(backtest, ["--help"])
|
||||
assert result.exit_code == 0
|
||||
assert "回测引擎" in result.output
|
||||
assert "--strategy-file" in result.output
|
||||
assert "--cash" in result.output
|
||||
assert "--commission" in result.output
|
||||
|
||||
def test_missing_strategy_fails(self):
|
||||
"""测试不指定策略则失败。"""
|
||||
from easy_tdx.backtest.cli import backtest
|
||||
|
||||
runner = CliRunner()
|
||||
result = runner.invoke(backtest, ["SZ", "000001"])
|
||||
assert result.exit_code == 1
|
||||
assert "必须指定" in result.output or "错误" in result.output
|
||||
Reference in New Issue
Block a user