Power Quant CLI
本地行情准备、因子计算、选股、研究及策略回测;结果保存在本地 DuckDB 和文件。
安装
推荐通过 uv 安装独立工具环境:
uv tool install --python 3.12 powerquant-cli
pq --help
uv tool upgrade powerquant-cli
也支持在 Python 3.12+ 环境通过 pip install powerquant-cli 安装。
接入行情
向管理员申请账户及具备 market:read 权限的平台 API Token。登录 JWT 不用于行情请求。
首次配置一次,之后新开终端、切换目录仍可使用:
pq config set --market-url 'https://powerquant.cn/market/api/v1'
pq config token
pq config show
token 命令隐藏输入密钥,不加 Bearer,避免写入命令历史。show 显示地址、配置来源和是否已配置 Token,不显示密钥原文或前缀。
家庭 LAN 可配置 http://192.168.8.142:18026/market/api/v1;公网 IP 临时入口为 http://82.157.167.33/market/api/v1。公网 HTTP 会明文传输 Token,只适合已明确接受风险的临时接入;长期公网访问使用可信 HTTPS 或 SSH/WireGuard 加密链路。直接使用 https://82.157.167.33 与现有域名证书不匹配。
配置保存在当前系统用户的 ~/.powerquant/config.json,与工作目录无关,不自动加载 .env。这是本地明文配置:POSIX 新目录权限 700、文件权限 600;Windows 依赖用户目录 ACL,不声称加密存储。不要提交或分享该文件。
每项配置按环境变量 > 用户文件 > 默认值解析。默认地址为 http://localhost:8002/api/v1,默认 Token 为空。环境变量只影响当前终端及其启动的子进程,不改文件;显式空 Token 环境变量会覆盖已保存密钥。
PowerShell 临时覆盖示例:
$env:MARKET_BASE_URL="http://192.168.8.142:18026/market/api/v1"
$env:MARKET_API_TOKEN="管理员签发的完整平台Token"
删除已保存的配置:
pq config unset market-token
pq config unset market-url
随后准备本地行情快照:
pq examples --directory powerquant-examples
cd powerquant-examples/selection
pq data prepare --config prepare.json
按实际覆盖调整 prepare.json 的股票和日期,将返回 manifest_path 写入 compute.json、select.json;按示例 README 执行 compute、select 和 backtest。不同使用目的的快照须分别通过完整性检查。
密钥到期或撤销后在线准备会失败,已下载快照仍可离线使用。行情密钥不用于定义发布;发布定义另使用 PQ_QUANT_URL/PQ_QUANT_TOKEN。默认本地目录为 ~/.powerquant。
Python
公开请求模型与调用入口位于 quant_cli.api,与 CLI 使用同一应用服务。
使用许可
自有代码采用随包附带的专有许可证:允许安装、查看源码、为自用进行修改,以及商业使用;未经书面授权不得再分发或转售本软件及其修改版本。第三方组件保留各自许可证。行情访问仍需要有效 Token;本许可证不授予行情数据的使用或再分发权。
Metadata
Release files for powerquant-cli 0.2.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| powerquant_cli-0.2.7.tar.gz | 453.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| powerquant_cli-0.2.7-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 898.1 kB
Release files / powerquant_cli-0.2.7.tar.gz
| Download URL | powerquant_cli-0.2.7.tar.gz |
|---|---|
| Size | 453.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
535f3da2d1520acb763174d06a7bc41e46cc77328ea8f262e1f458c1b309c2ef
|
|
BLAKE2b-256 checksum How to use checksums |
2c8923cd221438dc4981ffb2ac6186010409c311a1f9f74876298d5d07878b8d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.
Transparency logRelease files / powerquant_cli-0.2.7-py3-none-any.whl
| Download URL | powerquant_cli-0.2.7-py3-none-any.whl |
|---|---|
| Size | 444.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b77974fab3be0c85209018037139ad2df7ee719aa809ba2c20b9ef0512b79d23
|
|
BLAKE2b-256 checksum How to use checksums |
a37cd4c7516a11853a1939ce5955c1e169ec7718f1d8296ff49dc1dd9f37c9fd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.
Transparency log