QMT quantitative trading platform by 迅投 — built-in Python strategies, backtesting, and live trading for Chinese securities.
QMT (Quant Market Trading) is a professional quantitative trading platform by 迅投科技. It provides a full desktop client with built-in Python strategy development, backtesting, and live trading for Chinese securities.
⚠️ Requires broker account with QMT access. QMT runs on Windows. Available from brokers like 国金、华鑫、中泰、东方财富, etc.
| Mode | Description |
|---|---|
| QMT (full) | Full desktop GUI with built-in Python editor, charts, backtesting engine |
| miniQMT | Lightweight mode — external Python via xtquant SDK (see miniqmt skill) |
QMT provides an event-driven strategy framework with built-in Python (similar to JoinQuant/RiceQuant).
def init(ContextInfo):
"""Initialize — called once at strategy start"""
ContextInfo.set_universe(['000001.SZ', '600519.SH'])
def handlebar(ContextInfo):
"""Called on each bar (tick/1m/5m/1d etc.)"""
close = ContextInfo.get_market_data(['close'], stock_code='000001.SZ', period='1d', count=20)
# Trading logic here
def stop(ContextInfo):
"""Called when strategy stops"""
pass
def handlebar(ContextInfo):
# Get latest close prices (last 20 bars)
data = ContextInfo.get_market_data(
['open', 'high', 'low', 'close', 'volume'],
stock_code='000001.SZ',
period='1d',
count=20
)
# Get history data
history = ContextInfo.get_history_data(
20, '1d', 'close', stock_code='000001.SZ'
)
# Get sector stocks
stocks = ContextInfo.get_stock_list_in_sector('沪深A股')
# Get financial data
fin = ContextInfo.get_financial_data('000001.SZ')
def handlebar(ContextInfo):
# Buy 100 shares at market price
order_shares('000001.SZ', 100, 'fix', 11.50, ContextInfo)
# Sell 100 shares
order_shares('000001.SZ', -100, 'fix', 12.00, ContextInfo)
# Buy by target value
order_target_value('000001.SZ', 100000, 'fix', 11.50, ContextInfo)
# Cancel order
cancel('order_id', ContextInfo)
def handlebar(ContextInfo):
# Get positions
positions = get_trade_detail_data('your_account', 'stock', 'position')
for pos in positions:
print(pos.m_strInstrumentID, pos.m_nVolume, pos.m_dMarketValue)
# Get orders
orders = get_trade_detail_data('your_account', 'stock', 'order')
# Get account info
account = get_trade_detail_data('your_account', 'stock', 'account')
QMT includes a built-in backtesting engine:
def init(ContextInfo):
ContextInfo.capital = 1000000 # Initial capital
ContextInfo.set_commission(0.0003) # Commission rate
ContextInfo.set_slippage(0.01) # Slippage
ContextInfo.set_benchmark('000300.SH') # Benchmark index
import numpy as np
def init(ContextInfo):
ContextInfo.stock = '000001.SZ'
ContextInfo.set_universe([ContextInfo.stock])
ContextInfo.fast = 5
ContextInfo.slow = 20
def handlebar(ContextInfo):
stock = ContextInfo.stock
closes = ContextInfo.get_history_data(ContextInfo.slow + 1, '1d', 'close', stock_code=stock)
if len(closes) < ContextInfo.slow:
return
ma_fast = np.mean(closes[-ContextInfo.fast:])
ma_slow = np.mean(closes[-ContextInfo.slow:])
prev_fast = np.mean(closes[-ContextInfo.fast-1:-1])
prev_slow = np.mean(closes[-ContextInfo.slow-1:-1])
positions = get_trade_detail_data(ContextInfo.accID, 'stock', 'position')
holding = any(p.m_strInstrumentID == stock and p.m_nVolume > 0 for p in positions)
# Golden cross: buy
if prev_fast <= prev_slow and ma_fast > ma_slow and not holding:
order_shares(stock, 1000, 'fix', closes[-1], ContextInfo)
# Death cross: sell
elif prev_fast >= prev_slow and ma_fast < ma_slow and holding:
order_shares(stock, -1000, 'fix', closes[-1], ContextInfo)
| Category | Content |
|---|---|
| Stocks | A-shares (SH, SZ, BJ), Hong Kong Connect |
| Indices | All major indices |
| Futures | CFFEX, SHFE, DCE, CZCE, INE, GFEX |
| Options | ETF options, stock options, commodity options |
| ETFs | All exchange-traded funds |
| Bonds | Convertible bonds, treasury bonds |
| Periods | Tick, 1m, 5m, 15m, 30m, 1h, 1d, 1w, 1mon |
| Level2 | Order-by-order, trade-by-trade (broker dependent) |
| Financial | Balance sheet, income, cash flow, major indicators |
| Feature | QMT | miniQMT | Ptrade |
|---|---|---|---|
| Vendor | 迅投科技 | 迅投科技 | 恒生电子 |
| Python | Built-in (restricted) | External (any) | Built-in (restricted) |
| GUI | Full | Minimal | Full (web-based) |
| Backtesting | Built-in | Manual | Built-in |
| Deployment | Local | Local | Broker server (cloud) |
| Internet | Yes | Yes | No (intranet) |
xtquant SDK instead.ZIP package — ready to use