Skip to main content

qmtclient

PyPI Python Downloads Wheel License CI uv Ask Zread

远程 qmtserver 的轻量 Python 客户端 SDK。适用于没有 MiniQMT、没有 xtquant 的策略机、服务器或笔记本。

qmtclient  -- HTTP RPC / WebSocket / token -->  qmtserver + MiniQMT + xtquant

安装

使用 PyPI 安装:

uv pip install qmtclient

开发本仓库:

git clone https://github.com/gly11/qmtclient.git
cd qmtclient
uv sync

基础用法

from qmtclient import QmtClient

client = QmtClient("http://192.168.1.10:8000", token="dev-token")
print(client.health())
print(client.status())
print(client.xtdata.get_full_tick(["000001.SZ"]))

默认使用 qmtserver /v1。真实 token 不要写进源码,建议从环境变量读取。

策略接口

ticks = client.market.get_full_tick(["000001.SZ"])
daily = client.market.daily_bars(["000001.SZ"], start_time="20260501")
quality = client.market.daily_quality(
    ["000001.SZ"],
    start_time="2026-01-01",
    end_time="2026-01-31",
)
asset = client.account.asset("example-account")
orders = client.account.cached_orders(limit=20)

daily_bars、intraday_bars 和 instruments 优先使用 qmtserver 稳定 /v1/market 与 /v1/reference endpoints。直接 RPC 仍可用于 escape hatch。 account 只读查询优先使用 qmtserver 0.4.0 稳定 /v1/trader/* endpoints。

交易入口在 client.trading。它只组装参数并调用 qmtserver;是否允许真实交易由 qmtserver 的配置、保护和审计决定。

数据工具

job = client.batch.create_job(
    "market.daily_bars",
    {"codes": ["000001.SZ"], "start": "2026-01-01", "end": "2026-01-31"},
)
manifest = client.batch.download_snapshot(job["job_id"])

data_job = client.market_data.download(
    kind="daily_bars",
    symbols=["000001.SZ"],
    start="2026-01-01",
    end="2026-01-31",
)
data_jobs = client.market_data.jobs(status="succeeded", limit=50)
coverage = client.market_data.coverage(kind="daily_bars", symbols=["000001.SZ"])
bars = client.market_data.bars(kind="daily_bars", symbols=["000001.SZ"], limit=1000, offset=0)

created = client.snapshots.create(
    {
        "kind": "daily_bars",
        "symbols": ["000001.SZ"],
        "start": "2026-01-01",
        "end": "2026-01-31",
        "format": "csv",
    }
)

CLI

qmtclient check --base-url http://192.168.1.10:8000 --token-env QMTCLIENT_TOKEN
qmtclient diagnose --sample-code 000001.SZ --json
qmtclient runtime-health --json
qmtclient market-subscribe-check --symbol 000001.SZ --wait-seconds 10
qmtclient snapshot-verify .\snapshot\manifest.json

runtime-health 读取 qmtserver 运行健康摘要;market-subscribe-check 会输出订阅事件、 latest quotes 和 subscription diagnostics。CLI 只做诊断、只读冒烟检查和本地文件校验, 不提供真实交易快捷入口。

事件

for event in client.events(types=["stock_order", "stock_trade"]):
    print(event)

离线测试

from qmtclient import FakeQmtClient

fake = FakeQmtClient.from_fixture("examples/fixtures/market_daily.json")
print(fake.market.daily_bars(["000001.SZ"]))

边界

  • 不直接连接 MiniQMT。
  • 不依赖 xtquant。
  • 不绕过 qmtserver 的 token、RPC 白名单、透明 RPC 开关或交易保护。
  • 不做 GUI。

文档

开发检查

uv run python -m unittest discover -s tests
uv run ruff check .
uv run ruff format --check .
uv run ty check

Metadata

Release files for qmtclient 0.8.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for qmtclient 0.8.0
File Size Uploaded Provenance Actions
qmtclient-0.8.0.tar.gz 70.5 kB With provenance Details for qmtclient-0.8.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for qmtclient 0.8.0
File Interpreter ABI Platform Actions
qmtclient-0.8.0-py3-none-any.whl Python 3 none any Details for qmtclient-0.8.0-py3-none-any.whl

Total release size: 103.2 kB

Release files / qmtclient-0.8.0.tar.gz

Download URL qmtclient-0.8.0.tar.gz
Size 70.5 kB
Tags Source
SHA-256 checksum
How to use checksums
f27d1c9b9decff383f0a103ff4a180666d4cd7eee954e5d2de93cdee67f64ef9
BLAKE2b-256 checksum
How to use checksums
580b3f08ba1b136ce2ad1e164be0d0476ec53926ebe6cdce1dc951a3e9ee203f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jun 2, 2026.

Transparency log

Release files / qmtclient-0.8.0-py3-none-any.whl

Download URL qmtclient-0.8.0-py3-none-any.whl
Size 32.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9601b8c304b75febf30818bc6d92dc79cc63275ba0639870d1a1195c0ef8af87
BLAKE2b-256 checksum
How to use checksums
2ff20d1fdc0facb9a4e1497a9ae9385e33ec6c17b3e67776195b8c50273e5d58
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jun 2, 2026.

Transparency log

Security for qmtclient 0.8.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for qmtclient-0.8.0.tar.gz

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 Jun 2, 2026.

Transparency log

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page