Skip to main content

Remote xtquant service based on a layered xqshare fork

Project description

qmt-api

基于 fork xqshare 的远程 xtquant 服务,通过 RPyC 透明代理实现 Linux 策略机调用 Windows QMT 的完整链路。

架构

Linux 策略机                          Windows 服务机
┌─────────────────────┐              ┌──────────────────────┐
│  策略代码            │   RPyC      │  qmt-api Service      │
│  pip install qmt-api │ ◄──────────► │  → xtquant            │
│                     │   TCP/SSL    │  → QMT/miniQMT        │
│  adapter.get_tick() │              │  → 券商交易服务器      │
│  trader.order_stock()│              │                       │
└─────────────────────┘              └──────────────────────┘

快速开始

Linux 客户端安装

# 从 GitHub 安装(不含 xtquant/pywin32)
pip install git+ssh://git@github.com/Judioljuse/qmt-api.git

# 或 HTTPS
pip install git+https://github.com/Judioljuse/qmt-api.git

Windows 服务端部署

# 克隆仓库
git clone git@github.com:Judioljuse/qmt-api.git
cd qmt-api

# 安装依赖(含 xtquant/pywin32/numpy/pandas)
uv sync --extra server

# 配置环境
Copy-Item deploy/env/.env.server.example .env
# 编辑 .env 填入 QMT 路径和账号

# 启动服务
uv run python -m qmt_api.upstream.xqshare_compat.server --port 18812

使用示例

import os
from qmt_api import XtQuantRemote, XtDataAdapter, XtTraderAdapter

# 连接 Windows 服务端(host/port 从环境变量或参数传入)
remote = XtQuantRemote(
    host=os.environ.get('XQSHARE_REMOTE_HOST'),
    port=int(os.environ.get('XQSHARE_REMOTE_PORT', '18812')),
    client_id='client-standard',
    client_secret='xqshare-default-secret'
)

# 行情查询
xtdata = XtDataAdapter(remote)
tick = xtdata.get_full_tick(['000001.SZ'])

# 交易查询
trader = XtTraderAdapter(remote, userdata_path='/dummy')
positions = trader.query_stock_positions('YOUR_ACCOUNT_ID')

remote.close()

自 v0.4.0 起支持顶层快捷导入,无需再写内部模块路径。 客户端不安装 xtquant,所有调用通过 RPyC 透明代理到 Windows 服务端。

更新

Linux 客户端更新

pip install --upgrade git+https://github.com/Judioljuse/qmt-api.git

Windows 服务端更新

git pull
uv sync --extra server
# 重启服务

文档

版本

当前版本:0.4.1

详见 CHANGELOG.mdGitHub Releases

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

qmt_api-0.4.1-py3-none-any.whl (43.9 kB view details)

Uploaded Python 3

File details

Details for the file qmt_api-0.4.1-py3-none-any.whl.

File metadata

  • Download URL: qmt_api-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 43.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for qmt_api-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 93b84c4eb8b686794f349dbb63daa44c990cea0c666e6ecad5a8a39d849375be
MD5 9ac692a64bb93244c359ec19ab40d49b
BLAKE2b-256 e6e018d740035a7c051f0bd496229830ae6ba15dbb34bf2d9a21b988f0e78313

See more details on using hashes here.

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