Skip to content
Agentmart
Submit a tool

qmt-bridge-trading

通过 QMT Bridge HTTP API 执行证券交易:持仓/资产/委托查询、单笔与批量下单、撤单、清仓。 在用户提到 qmt-bridge 交易、下单、持仓、清仓、撤单、查询资产,或需操作 miniQMT 账户时使用。 本文件随 QMT Trading Skill(qmt-trading-skill…

Skill by atorber

IndexedMIT★ 25
Write a review

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/atorber-qmt-bridge-trading

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

通过 QMT Bridge HTTP API 执行证券交易:持仓/资产/委托查询、单笔与批量下单、撤单、清仓。 在用户提到 qmt-bridge 交易、下单、持仓、清仓、撤单、查询资产,或需操作 miniQMT 账户时使用。 本文件随 QMT Trading Skill(qmt-trading-skill 仓库)发布于 skills/qmt-bridge-trading/SKILL.md。

Use cases: backend, finance

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md and code. Checked Oct 26, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found
Runs as
Python package

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/qmt-bridge-trading

What's inside

Skill name
qmt-bridge-trading
Description
通过 QMT Bridge HTTP API 执行证券交易:持仓/资产/委托查询、单笔与批量下单、撤单、清仓。 在用户提到 qmt-bridge 交易、下单、持仓、清仓、撤单、查询资产,或需操作 miniQMT 账户时使用。 本文件随 QMT Trading Skill(qmt-trading-skill 仓库)发布于 skills/qmt-bridge-trading/SKILL.md。
License
MIT
Instructions
249 lines in SKILL.md · view on GitHub

Before installing

  • Ships executable scripts
  • Instructions call the network

Files (5)

  • SKILL.md
  • _common.py · scripts/
  • liquidate.py · scripts/
  • place_order.py · scripts/
  • trading_status.py · scripts/

SKILL.md (first lines)

# QMT Trading Skill · 交易

> **发布位置**:`qmt-trading-skill` 仓库 `skills/qmt-bridge-trading/SKILL.md`。集成说明见 [`skills/README.md`](../README.md)、[路线图](../ROADMAP.md) 与文档 [agent-skills.md](../../docs/agent-skills.md)。相关 Skill:复盘 [execution-review](../qmt-bridge-execution-review/SKILL.md)、风控 [portfolio-risk](../qmt-bridge-portfolio-risk/SKILL.md)、撤单 [order-ops](../qmt-bridge-order-ops/SKILL.md)。

通过已部署的 **QMT Bridge** 服务(FastAPI + miniQMT)完成真实交易操作。服务端须在 **Windows** 上运行,并启用交易模块。

## 可执行脚本(优先使用)

在仓库根目录执行(需 `pip install -e .`,环境变量见 `.env`)。**优先调用脚本**,避免在对话中手写长 curl/Python;脚本只输出摘要,不 dump 全量 JSON。

| 脚本 | 作用 | 示例 |
|------|------|------|
| `scripts/trading_status.py` | 只读:health + 账户状态 + 持仓/资产摘要 | `python skills/qmt-bridge-trading/scripts/trading_status.py` |
| `scripts/place_order.py` | 单笔下单(默认预览) | `.../place_order.py 000001.SZ --buy --volume 100 --execute --confirm` |
| `scripts/liquidate.py` | 清仓计划/执行(默认预览) | `.../liquidate.py` → 确认后 `.../liquidate.py --execute --confirm` |

路径均相对于本 skill 目录:`skills/qmt-bridge-trading/scripts/`。

**实盘提交**须同时带 `--execute --confirm`(`place_order` / `liquidate`)。交易前先跑 `trading_status.py`。

## 前置检查(每次交易前)

1. **服务可用**:`GET /api/meta/health`(无需 Key)
2. **交易已启用**:启动参数含 `--trading` 或 `QMT_BRIDGE_TRADING_ENABLED=true`
3. **认证**:所有 `/api/trading/*` 请求头携带 `X-API-Key: <密钥>`(与服务端 `QMT_BRIDGE_API_KEY` 一致)
4. **账户**:多账户时传 `account_id`;留空则使用服务端默认户(`QMT_BRIDGE_DEFAULT_ACCOUNT` 指定 stock/credit)
5. **连接**:下单前建议 `GET /api/trading/account_status`,确认交易通道已连接

## 连接信息

从用户环境或项目 `.env` 读取(勿在对话中复述完整 API Key):

| 变量 | 含义 |
|------|------|
| `QMT_BRIDGE_HOST` / 用户提供的 IP | 服务端地址 |
| `QMT_BRIDGE_PORT` | 端口,默认 `8000` |
| `QMT_BRIDGE_API_KEY` | 交易认证密钥 |
| `QMT_BRIDGE_STOCK_ACCOUNT_ID` | 普通证券账户(可选) |
| `QMT_BRIDGE_CREDIT_ACCOUNT_ID` | 信用两融账户(可选) |
| `QMT_BRIDGE_DEFAULT_ACCOUNT` | 默认户 `stock` / `credit`(默认 stock) |

**Python 客户端**(推荐,仓库已内置):

```python
from qmt_bridge import QMTClient

client = QMTClient(host="192.168.1.100", port=8000, api_key="***")
```

**curl**:所有交易请求加 `-H "X-API-Key: $QMT_BRIDGE_API_KEY"`。

## 核心常量

| 字段 | 值 | 说明 |
|------|-----|------|
| `order_type` | `23` | 买入 |
| `order_type` | `24` | 卖出 |
| `price_type` | `5` | 最新价(默认) |
| `price_type` | `11` | 限价(须填 `price`) |
| `price_type` | `42` | 最优五档即时成交剩余撤销 |

**股票代码**:`代码.交易所`,如 `000001.SZ`、`600519.SH`。

**数量**:A 股通常为 100 的整数倍;卖出时使用 **`can_use_volume`(可用数量)**,勿超过持仓。

## 操作流程

### 1. 查询持仓

```bash
python skills/qmt-bridge-trading/scripts/trading_status.py
```

或 API / 客户端:

```python
resp = client.query_positions(account_id="")  # 可选 account_id
positions = resp.get("data", resp)
```

持仓记录常用字段:`stock_code`、`volume`(总持仓)、`can_use_volume`(可卖)、`open_price`、`market_value`。

**单标的持仓**:`GET /api/trading/position/{stock_code}` 或 `client.query_single_position("000001.SZ")`。

### 2. 查询资产与委托(辅助)

```python
asset = client.query_asset()           # 资金、市值等
orders = client.query_orders()         # 当日委托;cancelable_only=True 仅可撤
trades = client.query_trades()         # 当日成交
```

### 3. 单笔下单

**执行前必须向用户确认**:标的、方向、数量、价格类型与价格。

```bash
# 预览
python skills/qmt-bridge-trading/scripts/place_order.py 000001.SZ --buy --volume 100
# 提交
python skills/qmt-bridge-trading/scripts/place_order.py 000001.SZ --buy --volume 100 --execute --confirm
```

```python
result = client.place_order(
    stock_code="000001.SZ",
    order_type=23,           # 买入
    order_volume=100,
    price_type=5,            # 最新价
    price=0.0,
    strategy_name="",
    order_remark="agent",
    account_id="",
)
# 返回示例: {"order_id": <int>, "status": "submitted"}
```

```bash
curl -s -X POST "http://HOST:PORT/api/trading/order" \

From atorber/qmt-trading-skill, MIT.

More from atorber/qmt-trading-skill

Signals

Stars
25
Forks
7
Open issues
0
Last commit (this folder)
Aug 14, 2026 (2 months ago)

From GitHub (fetched Oct 24, 2026).

Details

License
MIT
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from atorber

Cite this page

qmt-bridge-trading skill. Agent Mart. https://agentmart.dev/skills/atorber-qmt-bridge-trading (last updated 2026-10-24)