hamuna-quant-cli 0.1.0.dev93__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,117 @@
1
+ # hamuna-quant-cli
2
+
3
+ A 股回测 + 实盘统一 CLI (akquant 0.3.x).
4
+
5
+ 替代 v1 自建 driver (`hamuna-strategy`) + QMT-style (`init/handlebar/passorder`).
6
+ **同一份策略代码天然兼容回测与实盘** (akquant `Strategy` 双引擎一等公民).
7
+
8
+ ## 安装
9
+
10
+ ```bash
11
+ pip install hamuna-quant-cli
12
+ # 或本地源码装
13
+ pip install -e /path/to/hamuna-strategy-platform
14
+ # 或本地 wheel
15
+ pip install /path/to/hamuna_quant_cli-*.whl
16
+ ```
17
+
18
+ **Windows / macOS / Linux 全支持** (Python ≥3.10).
19
+
20
+ 依赖: `akquant>=0.3.41,<0.4` (Rust + Python 混合引擎).
21
+
22
+ ## 构建 (版本号自动更新)
23
+
24
+ 每次构建版本号自动 +1 (基于 git 提交数):
25
+
26
+ ```bash
27
+ # 一键: 先 bump 版本 → 再 build wheel + sdist
28
+ bash scripts/build_python.sh
29
+
30
+ # 或手动两步 (效果相同)
31
+ python3 scripts/bump_version.py --python
32
+ python3 -m build
33
+ ```
34
+
35
+ 产物在 `dist/`。版本格式 `0.1.0.dev<git提交数>` (PEP 440),同一 commit 版本可重现。
36
+
37
+ ## 子命令一览
38
+
39
+ | 命令 | 用途 |
40
+ |---|---|
41
+ | `hamuna_quant_cli run <strategy.py> --config cfg.json` | 跑 akquant backtest → result.json |
42
+ | `hamuna_quant_cli check <strategy.py> --config cfg.json` | 8 条纪律静态审查 (不回测) |
43
+ | `hamuna_quant_cli upload <strategy_id> --result result.json` | PUT metrics → server |
44
+ | `hamuna_quant_cli create --name ... --config ...` | 新建 strategy 拿 strategy_id |
45
+ | `hamuna_quant_cli parity` | 5 内置 strategy × 1 universe parity test |
46
+ | `hamuna_quant_cli qmt-translate <strategy.py> cfg.json` | akquant → QMT body 翻译 (本地 stub) |
47
+ | `hamuna_quant_cli commit <strategy_id>` | 5 步打包上传 (translate + bundle + PUT + POST + export) |
48
+ | `hamuna_quant_cli dataset {list\|fetch\|manifest}` | prebuilt 数据集管理 |
49
+ | `hamuna_quant_cli live run <strategy.py>` | **实盘 / 仿真运行** (包装 akquant.run_live) |
50
+
51
+ ## 端到端回测 (10 行)
52
+
53
+ ```bash
54
+ # 0) 安装
55
+ pip install hamuna-quant-cli
56
+
57
+ # 1) 写策略
58
+ cat > /tmp/s.py <<'EOF'
59
+ # coding: utf-8
60
+ from akquant import Strategy
61
+ class S(Strategy):
62
+ warmup_period = 1
63
+ def on_bar(self, bar):
64
+ if self.get_position(bar.symbol) == 0:
65
+ self.buy(bar.symbol, 100)
66
+ EOF
67
+
68
+ # 2) 写 cfg
69
+ cat > /tmp/c.json <<'EOF'
70
+ {
71
+ "backtest_start": "20240701",
72
+ "backtest_end": "20241231",
73
+ "pool": {"hs300": {"codes": ["600000.SH", "600036.SH"]}},
74
+ "init_capital": 1000000.0
75
+ }
76
+ EOF
77
+
78
+ # 3) 静态审查
79
+ hamuna_quant_cli check /tmp/s.py --config /tmp/c.json
80
+ # 期望 stderr: "纪律 self-check 通过 (0 条)"
81
+
82
+ # 4) 跑回测
83
+ hamuna_quant_cli run /tmp/s.py --config /tmp/c.json --output /tmp/r.json
84
+
85
+ # 5) 上传 (auto-create strategy)
86
+ hamuna_quant_cli upload --name "v2_smoke" --config /tmp/c.json --code /tmp/s.py --result /tmp/r.json
87
+ ```
88
+
89
+ ## 实盘 (5 行)
90
+
91
+ ```bash
92
+ # 1) 写策略 (同上)
93
+
94
+ # 2) paper 模式 (smoke, 不连真实 broker)
95
+ hamuna_quant_cli live run /tmp/s.py \
96
+ --mode paper --broker replay --symbols sh600000,sz600036 --duration 30s
97
+
98
+ # 3) qmt 实盘 (需配 broker=qmt + market_broker=qmt_market + gateway_options)
99
+ hamuna_quant_cli live run /tmp/s.py \
100
+ --mode broker_live --broker qmt --market-broker qmt_market \
101
+ --symbols sh600000,sz600036 \
102
+ --gateway-options "qmt_account_id=8888888888,qmt_base_url=http://127.0.0.1:9000"
103
+ ```
104
+
105
+ ## 不在 hamuna-quant-cli 范畴
106
+
107
+ - ❌ 5m / tick / 多周期 (akquant 0.3.x Phase B 锁日线)
108
+ - ❌ ETF / 期权 / 期货 (akquant 仅股票)
109
+ - ❌ 自建回测引擎 / 私有 IR / DSL (ADR-001/002 禁止)
110
+ - ❌ realtime dashboard / live trading 控制台 (v2 是离线回测 + 一次性实盘 run)
111
+
112
+ ## 关联文档
113
+
114
+ - 项目根: `../CLAUDE.md`
115
+ - v2 skill (skill 文档, 不再含代码): `../skills/hamuna-strategy-v2/SKILL.md`
116
+ - AKQuant Guide (引擎手册): `../docs/AKQUANT_GUIDE.md`
117
+ - v1 skill (旧, QMT-style 不变): `../skills/hamuna-strategy/`
@@ -0,0 +1,17 @@
1
+ """hamuna_quant_cli — A 股回测 + 实盘统一 CLI (akquant 0.3.x).
2
+
3
+ Pip 包名: hamuna-quant-cli
4
+ 入口命令: hamuna_quant_cli (console_script) / python -m hamuna_quant_cli
5
+
6
+ 子命令:
7
+ 回测: run / check / upload / create / parity / qmt-translate / commit / dataset
8
+ 实盘: live run
9
+
10
+ 替代 v1 自建 driver (hamuna-strategy) + QMT 风格 (init/handlebar); 上接 hamuna
11
+ server (13-key metrics schema). 全部走 akquant 0.3.x 引擎.
12
+ """
13
+ from __future__ import annotations
14
+
15
+ # 版本号由 scripts/bump_version.py 每次 build 自动更新 (基于 git 提交数).
16
+ # 格式: 0.1.0.dev<git提交数> (PEP 440). 手动改这里会被下一次 build 覆盖.
17
+ __version__ = "0.1.0.dev93"