This release is a pre-release and may not be stable for production use.
qmt-rpyc
qmt-rpyc 通过 RPyC 将 Windows QMT/MiniQMT 中的 broker-customized
xtquant SDK 暴露给 Linux、macOS 和 Windows 客户端。
当前版本为
0.3.0rc3。请先在模拟或只读环境验证,再用于实盘。
安装
客户端
要求 Python 3.9 或更高版本。
pip install qmt-rpyc
qmt-rpyc-client init --profile office
qmt-rpyc-client check --profile office
Python SDK:
from qmt_rpyc import QmtClient
with QmtClient.connect(
"192.168.1.20",
port=18812,
auth_key="shared-secret-123456",
) as client:
print(client.health())
print(client.xtdata.get_instrument_detail("600000.SH"))
也可以使用初始化后的 profile:
from qmt_rpyc import QmtClient
with QmtClient.connect_profile("office") as client:
print(client.health())
Windows 服务端
要求:
- MiniQMT 已安装、登录并运行。
- 64 位 Python 3.10 或 3.11,与券商
xtquant扩展匹配。 - 安装期间能够访问 PyPI。
从 GitHub Release 解压 Windows 安装包后运行:
install-server.bat
安装器在 %LOCALAPPDATA%\qmt-rpyc 创建专用虚拟环境,然后进入配置
向导。也可手工安装:
py -3.11 -m venv %LOCALAPPDATA%\qmt-rpyc\venv
%LOCALAPPDATA%\qmt-rpyc\venv\Scripts\pip.exe install "qmt-rpyc[server]"
%LOCALAPPDATA%\qmt-rpyc\venv\Scripts\qmt-rpyc-server.exe init
日常操作:
qmt-rpyc-server check
qmt-rpyc-server start
qmt-rpyc-server status
start 在前台运行,启动时如果无法连接 MiniQMT 或订阅配置账户会直接
失败。运行过程中断线仍会执行心跳检查和指数退避重连。
动态 CLI
API 列表和帮助来自实际 Windows 部署:
qmt-rpyc-client api --profile office list xtdata
qmt-rpyc-client api --profile office describe trader query_stock_asset
调用只接受 JSON:
qmt-rpyc-client call --profile office xtdata get_full_tick \
--args '[["600000.SH"]]'
qmt-rpyc-client call --profile office trader query_stock_asset \
--args '["YOUR_ACCOUNT_ID"]'
交易方法必须显式确认:
qmt-rpyc-client call --profile office trader order_stock \
--args '["YOUR_ACCOUNT_ID","600000.SH",23,100,5,10.0]' \
--confirm-trading
未知写操作要求 --confirm-write。带 callback 参数的方法首版不支持
CLI 调用。
事件、下载和自检:
qmt-rpyc-client events --profile office --types order,trade,disconnect
qmt-rpyc-client download --profile office start download_history_data \
--args '["600000.SH","1d","20240101","20241231"]'
qmt-rpyc-client download --profile office status TASK_ID
qmt-rpyc-client self-test --profile office
配置
服务端默认配置:
%LOCALAPPDATA%\qmt-rpyc\config.env
qmt-rpyc-server init 会:
- 尝试读取当前目录
.env,确认后导入。 - 探测运行中的 MiniQMT、
userdata_mini、账户和xtquant。 - 推荐私有 LAN 地址,不静默绑定所有网卡。
- 默认生成强认证密钥,也允许用户自定义。
- 经确认后在受管 venv 中建立指向券商
xtquant的 junction。
客户端 profile 使用平台标准配置目录。认证密钥默认保存到 Windows Credential Manager、macOS Keychain 或 Linux Secret Service。没有可用 keyring 时,可选择环境变量、每次隐藏输入或明确确认后的配置文件存储。
配置优先级:
命令行 > 环境变量 > profile > 默认值
安全边界
- HMAC 在创建 RPyC Connection 之前完成,未认证连接无法进入 RPyC/pickle 协议层。
- 认证后保留
rpyc.classic.obtain(),响应一次性物化为本地对象。 - 共享密钥持有者对该服务实例拥有完整信任,可以访问全部账户数据和交易 API。
- HMAC 只认证,不加密流量。仅应部署在受信任私有网络;跨公网或不可信 网络必须使用 TLS 或 VPN。
- 防火墙规则只能通过显式的
qmt-rpyc-server firewall add/remove管理。 - 安全问题请按 SECURITY.md 私密报告。
迁移
0.3.0 使用新的专用命名空间,不提供旧包兼容层:
# 旧
from client import QmtClient
# 新
from qmt_rpyc import QmtClient
完整说明见 MIGRATION.md。
开发与测试
python -m venv .venv
.venv/bin/python -m pip install -e ".[dev]"
.venv/bin/python -m pytest tests/ -v -k "not live"
真实 QMT 测试:
scripts\test_server.bat
法律声明
本项目不包含、不分发 xtquant、QMT 或 MiniQMT。相关软件、商标、数据和
许可归其权利方所有。本项目不提供投资建议;实盘交易和部署风险由使用者
自行承担。
本项目采用 MIT License。
Release files for qmt-rpyc 0.3.0rc3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| qmt_rpyc-0.3.0rc3.tar.gz | 69.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| qmt_rpyc-0.3.0rc3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 121.5 kB
Release files / qmt_rpyc-0.3.0rc3.tar.gz
| Download URL | qmt_rpyc-0.3.0rc3.tar.gz |
|---|---|
| Size | 69.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
edc74853eaa1c59d9bdbd6498aa601f1ebd5e8da67d69b35b14298789e3a969e
|
|
BLAKE2b-256 checksum How to use checksums |
b0b1e4fcf723fb95f2bec5bfb2963dad8e9f626b9de25ab728f4f4c39b19af53
|
| 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 Jul 29, 2026.
Transparency logRelease files / qmt_rpyc-0.3.0rc3-py3-none-any.whl
| Download URL | qmt_rpyc-0.3.0rc3-py3-none-any.whl |
|---|---|
| Size | 52.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c0b248a621341b8aa34b9758f5eaaeafa91356bbe8ac0252d4f83e5ae01e2038
|
|
BLAKE2b-256 checksum How to use checksums |
26776d89ae73ffbb9cfe5420ba0ef4bca63ee3b4dd5f01b5f414fdbfb8101866
|
| 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 Jul 29, 2026.
Transparency log