hamuna-quant-cli
A 股回测 + 实盘统一 CLI (akquant 0.3.x).
替代 v1 自建 driver (hamuna-strategy) + QMT-style (init/handlebar/passorder).
同一份策略代码天然兼容回测与实盘 (akquant Strategy 双引擎一等公民).
安装
pip install hamuna-quant-cli
# 或本地源码装
pip install -e /path/to/hamuna-strategy-platform
# 或本地 wheel
pip install /path/to/hamuna_quant_cli-*.whl
Windows / macOS / Linux 全支持 (Python ≥3.10).
依赖: akquant>=0.3.41,<0.4 (Rust + Python 混合引擎).
构建 (版本号自动更新)
每次构建版本号自动 +1 (基于 git 提交数):
# 一键: 先 bump 版本 → 再 build wheel + sdist
bash scripts/build_python.sh
# 或手动两步 (效果相同)
python3 scripts/bump_version.py --python
python3 -m build
产物在 dist/。版本格式 0.1.0.dev<git提交数> (PEP 440),同一 commit 版本可重现。
子命令一览
| 命令 | 用途 |
|---|---|
hamuna_quant_cli run <strategy.py> --config cfg.json |
跑 akquant backtest → result.json |
hamuna_quant_cli check <strategy.py> --config cfg.json |
8 条纪律静态审查 (不回测) |
hamuna_quant_cli upload <strategy_id> --result result.json |
PUT metrics → server |
hamuna_quant_cli create --name ... --config ... |
新建 strategy 拿 strategy_id |
hamuna_quant_cli parity |
5 内置 strategy × 1 universe parity test |
hamuna_quant_cli qmt-translate <strategy.py> cfg.json |
akquant → QMT body 翻译 (本地 stub) |
hamuna_quant_cli commit <strategy_id> |
5 步打包上传 (translate + bundle + PUT + POST + export) |
hamuna_quant_cli dataset {list|fetch|manifest} |
prebuilt 数据集管理 |
hamuna_quant_cli live run <strategy.py> |
实盘 / 仿真运行 (包装 akquant.run_live) |
端到端回测 (10 行)
# 0) 安装
pip install hamuna-quant-cli
# 1) 写策略
cat > /tmp/s.py <<'EOF'
# coding: utf-8
from akquant import Strategy
class S(Strategy):
warmup_period = 1
def on_bar(self, bar):
if self.get_position(bar.symbol) == 0:
self.buy(bar.symbol, 100)
EOF
# 2) 写 cfg
cat > /tmp/c.json <<'EOF'
{
"backtest_start": "20240701",
"backtest_end": "20241231",
"pool": {"hs300": {"codes": ["600000.SH", "600036.SH"]}},
"init_capital": 1000000.0
}
EOF
# 3) 静态审查
hamuna_quant_cli check /tmp/s.py --config /tmp/c.json
# 期望 stderr: "纪律 self-check 通过 (0 条)"
# 4) 跑回测
hamuna_quant_cli run /tmp/s.py --config /tmp/c.json --output /tmp/r.json
# 5) 上传 (auto-create strategy)
hamuna_quant_cli upload --name "v2_smoke" --config /tmp/c.json --code /tmp/s.py --result /tmp/r.json
实盘 (5 行)
# 1) 写策略 (同上)
# 2) qmt 实盘 (需配 broker=qmt + market_broker=qmt_market + gateway_options)
# Round 18.63.18: paper 模式已删 — 模拟由 QMT 客户端原生「模拟信号模式」承担
hamuna_quant_cli live run /tmp/s.py \
--mode broker_live --broker qmt --market-broker qmt_market \
--symbols sh600000,sz600036 \
--gateway-options "qmt_account_id=8888888888,qmt_base_url=http://127.0.0.1:9000"
不在 hamuna-quant-cli 范畴
- ❌ 5m / tick / 多周期 (akquant 0.3.x Phase B 锁日线)
- ❌ ETF / 期权 / 期货 (akquant 仅股票)
- ❌ 自建回测引擎 / 私有 IR / DSL (ADR-001/002 禁止)
- ❌ realtime dashboard / live trading 控制台 (v2 是离线回测 + 一次性实盘 run)
关联文档
- 项目根:
../CLAUDE.md - v2 skill (skill 文档, 不再含代码):
../skills/hamuna-strategy-v2/SKILL.md - AKQuant Guide (引擎手册):
../docs/AKQUANT_GUIDE.md - v1 skill (旧, QMT-style 不变):
../skills/hamuna-strategy/
Metadata
Release files for hamuna-quant-cli 0.1.26
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| hamuna_quant_cli-0.1.26.tar.gz | 149.5 kB | Without provenance | Details for hamuna_quant_cli-0.1.26.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| hamuna_quant_cli-0.1.26-py3-none-any.whl | Python 3 | none | any | Details for hamuna_quant_cli-0.1.26-py3-none-any.whl |
Total release size: 312.2 kB
Release files / hamuna_quant_cli-0.1.26.tar.gz
| Download URL | hamuna_quant_cli-0.1.26.tar.gz |
|---|---|
| Size | 149.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3f78b5c09f2d43c439941d1addfde3b9a42866b45e0e0a4ae0bc75d6e801d8db
|
|
BLAKE2b-256 checksum How to use checksums |
d01572ca0cd3318e8b1ad5a1b483887e028f6493025440d9ae167d4ad2e9d803
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.13
|
Release files / hamuna_quant_cli-0.1.26-py3-none-any.whl
| Download URL | hamuna_quant_cli-0.1.26-py3-none-any.whl |
|---|---|
| Size | 162.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f3071e7c5bcb03fad329c80ef3b397895cb0d11a8a31bf1e8e493f1e99ab0d8c
|
|
BLAKE2b-256 checksum How to use checksums |
7d3c1d67268c388d52c4d6d45137c3461589486bf7d91477bd263f81c24f6b95
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.13
|
Security for hamuna-quant-cli 0.1.26
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.