Skip to main content

Python client SDK for qmtserver remote MiniQMT gateways.

Project description

qmtclient

PyPI Python License CI 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_barsintraday_barsinstruments 优先使用 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"])

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 market-subscribe-check --symbol 000001.SZ --wait-seconds 10
qmtclient snapshot-verify .\snapshot\manifest.json

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

qmtclient-0.6.0.tar.gz (61.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

qmtclient-0.6.0-py3-none-any.whl (27.8 kB view details)

Uploaded Python 3

File details

Details for the file qmtclient-0.6.0.tar.gz.

File metadata

  • Download URL: qmtclient-0.6.0.tar.gz
  • Upload date:
  • Size: 61.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for qmtclient-0.6.0.tar.gz
Algorithm Hash digest
SHA256 82c3871d28d2b8a3af08111f42e1476d7877e85dbf4317f0c8334ba83752ff73
MD5 cfd60209dc7df1d8c213942c1c12b9f8
BLAKE2b-256 ffe7ca3028443e68ea38b1ae086e990c5310b804fa560be73065e94887155f3d

See more details on using hashes here.

Provenance

The following attestation bundles were made for qmtclient-0.6.0.tar.gz:

Publisher: publish.yml on gly11/qmtclient

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file qmtclient-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: qmtclient-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 27.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for qmtclient-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 14f6ad703fd147fb9359ee07ebd2aafdc6509eb34b2774ae2e07cefcd4bb35ac
MD5 d6369f76982ac66ad3e356cffc1fbaa5
BLAKE2b-256 52aba009ac68f95a2a2d024acb614f86f3c801216791e28cd5a975b1500581f5

See more details on using hashes here.

Provenance

The following attestation bundles were made for qmtclient-0.6.0-py3-none-any.whl:

Publisher: publish.yml on gly11/qmtclient

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page