hamuna-quant-cli 0.1.0.dev93__tar.gz

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.
Files changed (40) hide show
  1. hamuna_quant_cli-0.1.0.dev93/MANIFEST.in +4 -0
  2. hamuna_quant_cli-0.1.0.dev93/PKG-INFO +154 -0
  3. hamuna_quant_cli-0.1.0.dev93/README.md +163 -0
  4. hamuna_quant_cli-0.1.0.dev93/hamuna_quant_cli/README.md +117 -0
  5. hamuna_quant_cli-0.1.0.dev93/hamuna_quant_cli/__init__.py +17 -0
  6. hamuna_quant_cli-0.1.0.dev93/hamuna_quant_cli/__main__.py +978 -0
  7. hamuna_quant_cli-0.1.0.dev93/hamuna_quant_cli/_market_fallback.py +82 -0
  8. hamuna_quant_cli-0.1.0.dev93/hamuna_quant_cli/_metrics_15.py +342 -0
  9. hamuna_quant_cli-0.1.0.dev93/hamuna_quant_cli/_test_akquant_parity.py +530 -0
  10. hamuna_quant_cli-0.1.0.dev93/hamuna_quant_cli/akquant_data_adapter.py +295 -0
  11. hamuna_quant_cli-0.1.0.dev93/hamuna_quant_cli/akquant_runner.py +620 -0
  12. hamuna_quant_cli-0.1.0.dev93/hamuna_quant_cli/akquant_schema_adapter.py +443 -0
  13. hamuna_quant_cli-0.1.0.dev93/hamuna_quant_cli/base_strategy.py +80 -0
  14. hamuna_quant_cli-0.1.0.dev93/hamuna_quant_cli/cross_sectional_helpers.py +118 -0
  15. hamuna_quant_cli-0.1.0.dev93/hamuna_quant_cli/live/__init__.py +25 -0
  16. hamuna_quant_cli-0.1.0.dev93/hamuna_quant_cli/live/loader.py +121 -0
  17. hamuna_quant_cli-0.1.0.dev93/hamuna_quant_cli/live/qmt_broker.py +683 -0
  18. hamuna_quant_cli-0.1.0.dev93/hamuna_quant_cli/live/qmt_market.py +448 -0
  19. hamuna_quant_cli-0.1.0.dev93/hamuna_quant_cli/live/runner.py +449 -0
  20. hamuna_quant_cli-0.1.0.dev93/hamuna_quant_cli/prebuilt_downloader.py +263 -0
  21. hamuna_quant_cli-0.1.0.dev93/hamuna_quant_cli/prebuilt_resolver.py +470 -0
  22. hamuna_quant_cli-0.1.0.dev93/hamuna_quant_cli/qmt_translator.py +609 -0
  23. hamuna_quant_cli-0.1.0.dev93/hamuna_quant_cli/runtime/__init__.py +2 -0
  24. hamuna_quant_cli-0.1.0.dev93/hamuna_quant_cli/runtime/backtest.py +38 -0
  25. hamuna_quant_cli-0.1.0.dev93/hamuna_quant_cli/runtime/cache.py +255 -0
  26. hamuna_quant_cli-0.1.0.dev93/hamuna_quant_cli/runtime/discipline.py +359 -0
  27. hamuna_quant_cli-0.1.0.dev93/hamuna_quant_cli/runtime/http_client.py +209 -0
  28. hamuna_quant_cli-0.1.0.dev93/hamuna_quant_cli/runtime/s3client.py +109 -0
  29. hamuna_quant_cli-0.1.0.dev93/hamuna_quant_cli/runtime/server_client.py +285 -0
  30. hamuna_quant_cli-0.1.0.dev93/hamuna_quant_cli/scripts/server.json +4 -0
  31. hamuna_quant_cli-0.1.0.dev93/hamuna_quant_cli.egg-info/PKG-INFO +154 -0
  32. hamuna_quant_cli-0.1.0.dev93/hamuna_quant_cli.egg-info/SOURCES.txt +38 -0
  33. hamuna_quant_cli-0.1.0.dev93/hamuna_quant_cli.egg-info/dependency_links.txt +1 -0
  34. hamuna_quant_cli-0.1.0.dev93/hamuna_quant_cli.egg-info/entry_points.txt +2 -0
  35. hamuna_quant_cli-0.1.0.dev93/hamuna_quant_cli.egg-info/requires.txt +18 -0
  36. hamuna_quant_cli-0.1.0.dev93/hamuna_quant_cli.egg-info/top_level.txt +1 -0
  37. hamuna_quant_cli-0.1.0.dev93/pyproject.toml +89 -0
  38. hamuna_quant_cli-0.1.0.dev93/setup.cfg +4 -0
  39. hamuna_quant_cli-0.1.0.dev93/tests/test_live_safety.py +52 -0
  40. hamuna_quant_cli-0.1.0.dev93/tests/test_skeleton.py +154 -0
@@ -0,0 +1,4 @@
1
+ include hamuna_quant_cli/README.md
2
+ include hamuna_quant_cli/scripts/*.json
3
+ recursive-exclude * __pycache__
4
+ recursive-exclude * *.py[cod]
@@ -0,0 +1,154 @@
1
+ Metadata-Version: 2.4
2
+ Name: hamuna-quant-cli
3
+ Version: 0.1.0.dev93
4
+ Summary: Hamuna A 股回测 + 实盘统一 CLI (akquant 0.3.x). 替代 v1 自建 driver + QMT-style 策略规范.
5
+ Author-email: Hamuna Team <team@hamuna.example>
6
+ License: MIT
7
+ Project-URL: Homepage, https://hamuna.example
8
+ Project-URL: Bug Tracker, https://github.com/hamuna/hamuna-strategy-platform/issues
9
+ Keywords: quant,backtest,akquant,A-share,QMT,hamuna
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Financial and Insurance Industry
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Operating System :: Microsoft :: Windows
17
+ Classifier: Operating System :: POSIX :: Linux
18
+ Classifier: Operating System :: MacOS
19
+ Classifier: Topic :: Office/Business :: Financial :: Investment
20
+ Requires-Python: >=3.10
21
+ Description-Content-Type: text/markdown
22
+ Requires-Dist: akquant<0.4,>=0.3.41
23
+ Requires-Dist: pandas>=1.5
24
+ Requires-Dist: numpy>=1.23
25
+ Requires-Dist: pyarrow>=10
26
+ Requires-Dist: pyyaml>=6
27
+ Requires-Dist: requests>=2.28
28
+ Provides-Extra: dev
29
+ Requires-Dist: pytest>=7; extra == "dev"
30
+ Requires-Dist: pytest-cov>=4; extra == "dev"
31
+ Requires-Dist: ruff>=0.1; extra == "dev"
32
+ Provides-Extra: polars
33
+ Requires-Dist: polars>=0.20; extra == "polars"
34
+ Provides-Extra: backtest-extra
35
+ Requires-Dist: matplotlib>=3.7; extra == "backtest-extra"
36
+ Requires-Dist: plotly>=5.15; extra == "backtest-extra"
37
+
38
+ # hamuna-quant-cli
39
+
40
+ A 股回测 + 实盘统一 CLI (akquant 0.3.x).
41
+
42
+ 替代 v1 自建 driver (`hamuna-strategy`) + QMT-style (`init/handlebar/passorder`).
43
+ **同一份策略代码天然兼容回测与实盘** (akquant `Strategy` 双引擎一等公民).
44
+
45
+ ## 安装
46
+
47
+ ```bash
48
+ pip install hamuna-quant-cli
49
+ # 或本地源码装
50
+ pip install -e /path/to/hamuna-strategy-platform
51
+ # 或本地 wheel
52
+ pip install /path/to/hamuna_quant_cli-*.whl
53
+ ```
54
+
55
+ **Windows / macOS / Linux 全支持** (Python ≥3.10).
56
+
57
+ 依赖: `akquant>=0.3.41,<0.4` (Rust + Python 混合引擎).
58
+
59
+ ## 构建 (版本号自动更新)
60
+
61
+ 每次构建版本号自动 +1 (基于 git 提交数):
62
+
63
+ ```bash
64
+ # 一键: 先 bump 版本 → 再 build wheel + sdist
65
+ bash scripts/build_python.sh
66
+
67
+ # 或手动两步 (效果相同)
68
+ python3 scripts/bump_version.py --python
69
+ python3 -m build
70
+ ```
71
+
72
+ 产物在 `dist/`。版本格式 `0.1.0.dev<git提交数>` (PEP 440),同一 commit 版本可重现。
73
+
74
+ ## 子命令一览
75
+
76
+ | 命令 | 用途 |
77
+ |---|---|
78
+ | `hamuna_quant_cli run <strategy.py> --config cfg.json` | 跑 akquant backtest → result.json |
79
+ | `hamuna_quant_cli check <strategy.py> --config cfg.json` | 8 条纪律静态审查 (不回测) |
80
+ | `hamuna_quant_cli upload <strategy_id> --result result.json` | PUT metrics → server |
81
+ | `hamuna_quant_cli create --name ... --config ...` | 新建 strategy 拿 strategy_id |
82
+ | `hamuna_quant_cli parity` | 5 内置 strategy × 1 universe parity test |
83
+ | `hamuna_quant_cli qmt-translate <strategy.py> cfg.json` | akquant → QMT body 翻译 (本地 stub) |
84
+ | `hamuna_quant_cli commit <strategy_id>` | 5 步打包上传 (translate + bundle + PUT + POST + export) |
85
+ | `hamuna_quant_cli dataset {list\|fetch\|manifest}` | prebuilt 数据集管理 |
86
+ | `hamuna_quant_cli live run <strategy.py>` | **实盘 / 仿真运行** (包装 akquant.run_live) |
87
+
88
+ ## 端到端回测 (10 行)
89
+
90
+ ```bash
91
+ # 0) 安装
92
+ pip install hamuna-quant-cli
93
+
94
+ # 1) 写策略
95
+ cat > /tmp/s.py <<'EOF'
96
+ # coding: utf-8
97
+ from akquant import Strategy
98
+ class S(Strategy):
99
+ warmup_period = 1
100
+ def on_bar(self, bar):
101
+ if self.get_position(bar.symbol) == 0:
102
+ self.buy(bar.symbol, 100)
103
+ EOF
104
+
105
+ # 2) 写 cfg
106
+ cat > /tmp/c.json <<'EOF'
107
+ {
108
+ "backtest_start": "20240701",
109
+ "backtest_end": "20241231",
110
+ "pool": {"hs300": {"codes": ["600000.SH", "600036.SH"]}},
111
+ "init_capital": 1000000.0
112
+ }
113
+ EOF
114
+
115
+ # 3) 静态审查
116
+ hamuna_quant_cli check /tmp/s.py --config /tmp/c.json
117
+ # 期望 stderr: "纪律 self-check 通过 (0 条)"
118
+
119
+ # 4) 跑回测
120
+ hamuna_quant_cli run /tmp/s.py --config /tmp/c.json --output /tmp/r.json
121
+
122
+ # 5) 上传 (auto-create strategy)
123
+ hamuna_quant_cli upload --name "v2_smoke" --config /tmp/c.json --code /tmp/s.py --result /tmp/r.json
124
+ ```
125
+
126
+ ## 实盘 (5 行)
127
+
128
+ ```bash
129
+ # 1) 写策略 (同上)
130
+
131
+ # 2) paper 模式 (smoke, 不连真实 broker)
132
+ hamuna_quant_cli live run /tmp/s.py \
133
+ --mode paper --broker replay --symbols sh600000,sz600036 --duration 30s
134
+
135
+ # 3) qmt 实盘 (需配 broker=qmt + market_broker=qmt_market + gateway_options)
136
+ hamuna_quant_cli live run /tmp/s.py \
137
+ --mode broker_live --broker qmt --market-broker qmt_market \
138
+ --symbols sh600000,sz600036 \
139
+ --gateway-options "qmt_account_id=8888888888,qmt_base_url=http://127.0.0.1:9000"
140
+ ```
141
+
142
+ ## 不在 hamuna-quant-cli 范畴
143
+
144
+ - ❌ 5m / tick / 多周期 (akquant 0.3.x Phase B 锁日线)
145
+ - ❌ ETF / 期权 / 期货 (akquant 仅股票)
146
+ - ❌ 自建回测引擎 / 私有 IR / DSL (ADR-001/002 禁止)
147
+ - ❌ realtime dashboard / live trading 控制台 (v2 是离线回测 + 一次性实盘 run)
148
+
149
+ ## 关联文档
150
+
151
+ - 项目根: `../CLAUDE.md`
152
+ - v2 skill (skill 文档, 不再含代码): `../skills/hamuna-strategy-v2/SKILL.md`
153
+ - AKQuant Guide (引擎手册): `../docs/AKQUANT_GUIDE.md`
154
+ - v1 skill (旧, QMT-style 不变): `../skills/hamuna-strategy/`
@@ -0,0 +1,163 @@
1
+ # Hamuna.Trade 量化策略平台
2
+
3
+ React + Vite 前端、Go + Gin API、MongoDB 和 Redis 组成的本地可执行栈。
4
+
5
+ ## 一键启动(全本地,Docker 自带 Mongo + Redis + MinIO)
6
+
7
+ 前置条件:Docker Desktop(包含 Docker Compose)。
8
+
9
+ ```bash
10
+ copy .env.example .env
11
+ # 编辑 .env,至少更换 MONGO_PASSWORD 和 JWT_SECRET
12
+ docker compose up -d --build
13
+ docker compose ps
14
+ ```
15
+
16
+ 服务地址:
17
+
18
+ | 服务 | 地址 |
19
+ |---|---|
20
+ | Web 前端 | http://localhost:3000 |
21
+ | Go API | http://localhost:8080 |
22
+ | API 健康检查 | http://localhost:8080/health |
23
+ | 前端代理健康检查 | http://localhost:3000/health |
24
+ | MongoDB | mongodb://localhost:27017 |
25
+ | Redis | redis://localhost:6379 |
26
+
27
+ > 完整本地栈请改用 `docker-compose.local.yml` 旧版(Mongo + Redis + MinIO + Backend + Frontend 都在容器里)。当前根目录 `docker-compose.yml` 仅为生产部署使用。
28
+
29
+ ## 验证前后端闭环
30
+
31
+ 需要 Node.js 18 或更高版本:
32
+
33
+ ```bash
34
+ node scripts/smoke.mjs
35
+ ```
36
+
37
+ 数据库通过根目录 `.env` 配置;MongoDB 端口使用 `MONGO_PORT`,远程托管服务可直接设置 `MONGODB_URI` 覆盖全部 `MONGO_*` 字段。
38
+
39
+ 脚本会依次验证:
40
+
41
+ 1. API 健康检查
42
+ 2. 注册与登录
43
+ 3. JWT 鉴权后的策略、因子、模板和数据集查询
44
+ 4. API Key 创建与列表查询
45
+
46
+ 成功时每一步输出 `[OK]` 并以状态码 0 结束。可通过 `API_BASE` 指定 API 地址。
47
+
48
+ ## 本地开发
49
+
50
+ 数据库仍可使用容器:
51
+
52
+ ```bash
53
+ docker compose up -d mongo redis
54
+ ```
55
+
56
+ 后端需要 Go 1.22:
57
+
58
+ ```bash
59
+ cd backend
60
+ # 根目录 .env 支持 MONGO_HOST、MONGO_PORT、MONGO_USERNAME、
61
+ # MONGO_PASSWORD、MONGO_DATABASE,也可用 MONGODB_URI 整体覆盖。
62
+ go mod download
63
+ go run ./cmd/api
64
+ ```
65
+
66
+ 前端使用 Vite 代理 `/api` 和 `/health` 到 `http://localhost:8080`:
67
+
68
+ ```bash
69
+ cd frontend
70
+ npm ci
71
+ npm run dev
72
+ ```
73
+
74
+ 访问 http://localhost:3000。只有需要绕过 Vite/Nginx 代理时才设置 `VITE_API_BASE`。
75
+
76
+ ## 生产部署(Vercel + Docker)
77
+
78
+ 前端 = Vercel,后端 = Docker Compose;MongoDB / Redis / S3 全部使用托管服务。
79
+
80
+ ### 1. 准备托管服务
81
+
82
+ | 服务 | 推荐 |
83
+ |---|---|
84
+ | MongoDB | [MongoDB Atlas](https://www.mongodb.com/atlas) Free Tier → 拿 `MONGODB_URI` |
85
+ | Redis | [Upstash Redis](https://upstash.com/) 或 [Redis Cloud](https://redis.com/cloud/) → 拿 `REDIS_ADDR`(URL 形式含密码) |
86
+ | 对象存储 | AWS S3 / 阿里云 OSS / Tencent COS(S3 兼容)→ 拿 `S3_*` 凭证 |
87
+
88
+ ### 2. 部署后端(Docker)
89
+
90
+ ```bash
91
+ cp .env.example .env
92
+ # 编辑 .env,填入 MONGODB_URI / REDIS_ADDR / JWT_SECRET / HAMUNA_MASTER_KEY /
93
+ # S3_* / CORS_ALLOWED_ORIGINS / HAMUNA_CERT_API_BASE
94
+ nano .env
95
+ docker compose up -d --build
96
+ ```
97
+
98
+ 暴露 `8080`,前面套一层 TLS(Caddy / Nginx / Cloudflare 都可以)。验证:
99
+
100
+ ```bash
101
+ curl https://api.your-domain.com/health
102
+ ```
103
+
104
+ ### 3. 部署前端(Vercel)
105
+
106
+ - 在 Vercel New Project,**Root Directory = `frontend`**
107
+ - Framework Preset = Vite(自动检测)
108
+ - **Environment Variables**(Production):
109
+
110
+ | Name | Value |
111
+ |---|---|
112
+ | `VITE_API_BASE` | `https://api.your-domain.com` |
113
+
114
+ > 不要加 `/api` 后缀。Vite 代理在生产构建里被移除;`VITE_API_BASE` 直接替换 `/api/*` 的前缀。
115
+
116
+ 部署成功后访问 Vercel 给你的 `*.vercel.app` 域名。
117
+
118
+ ### 4. CORS 与回调
119
+
120
+ - 后端 `CORS_ALLOWED_ORIGINS` 必须包含 Vercel 域名:`https://your-app.vercel.app,https://hamuna.vercel.app`
121
+ - 后端 `HAMUNA_CERT_API_BASE` = `https://api.your-domain.com`(导出 QMT shell 回拨的目标)
122
+ - 修改 `.env` 后要 `docker compose up -d --force-recreate backend` 让后端重读环境变量
123
+
124
+ ### 5. 升级 / 回滚
125
+
126
+ - 前端:Vercel Git 集成直接 `git push` 触发
127
+ - 后端:`git pull && docker compose up -d --build backend`
128
+
129
+ ### 6. 调试清单
130
+
131
+ | 现象 | 检查 |
132
+ |---|---|
133
+ | 前端 401 / 网络失败 | 浏览器 Network 看 `/api/v1/*` 请求 URL;Vercel env `VITE_API_BASE` 是否正确(不要 `/api` 后缀) |
134
+ | CORS 报错 | 后端 `.env` 的 `CORS_ALLOWED_ORIGINS` 含 Vercel 域名;重启 backend |
135
+ | `/health` OK 但 `/api/v1/*` 报 502 | 后端到 Mongo/Redis 不通:`docker compose logs backend` |
136
+ | 数据集构建失败 | `S3_*` 凭证 / 桶名 / `S3_USE_SSL=true` 是否对(托管服务一般要 SSL) |
137
+
138
+ ## 项目结构
139
+
140
+ ```text
141
+ backend/ Go API、JWT、API Key 与 Mongo/Redis 访问
142
+ frontend/ Vite + React + TypeScript + Tailwind
143
+ frontend/app/exports/ Pencil 原始 HTML 导出,仅供设计对照
144
+ scripts/smoke.mjs 前后端 API 闭环检查
145
+ docker-compose.yml 完整本地运行栈
146
+ ```
147
+
148
+ ## 已接入 API
149
+
150
+ | Method | Path | 鉴权 |
151
+ |---|---|---|
152
+ | GET | `/health` | 公开 |
153
+ | POST | `/api/v1/auth/register` | 公开 |
154
+ | POST | `/api/v1/auth/login` | 公开 |
155
+ | GET | `/api/v1/strategies` | JWT |
156
+ | GET | `/api/v1/strategies/:id` | JWT |
157
+ | GET | `/api/v1/factors` | JWT |
158
+ | GET | `/api/v1/factor-templates` | JWT |
159
+ | GET | `/api/v1/datasets` | JWT |
160
+ | POST / GET | `/api/v1/api-keys` | JWT |
161
+ | GET | `/api/v1/cli/whoami` | API Key |
162
+
163
+ 当前后端尚未开放策略创建、运行回测和 API Key 删除接口,前端不会伪造这些操作的成功状态。
@@ -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"