Skip to content
Worix
BrowsePublish
Log inSign Up

QMT

QMT quantitative trading platform by 迅投 — built-in Python strategies, backtesting, and live trading for Chinese securities.

20 downloads
Free
Reviewed
backtest
china
futures
options
quantitative
stock
strategy
trading

QMT (迅投量化交易终端)

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.

Two modes

ModeDescription
QMT (full)Full desktop GUI with built-in Python editor, charts, backtesting engine
miniQMTLightweight mode — external Python via xtquant SDK (see miniqmt skill)

Built-in Python strategy framework

QMT provides an event-driven strategy framework with built-in Python (similar to JoinQuant/RiceQuant).

Strategy lifecycle

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

Get market data (built-in)

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')

Place orders (built-in)

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)

Query positions & account

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')

Backtesting

QMT includes a built-in backtesting engine:

  1. Write strategy in the built-in Python editor
  2. Set backtest parameters (date range, initial capital, commission, slippage)
  3. Click "Run Backtest"
  4. View results: equity curve, drawdown, Sharpe ratio, trade log

Backtest settings

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

Complete example: Dual MA strategy

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)

Data coverage

CategoryContent
StocksA-shares (SH, SZ, BJ), Hong Kong Connect
IndicesAll major indices
FuturesCFFEX, SHFE, DCE, CZCE, INE, GFEX
OptionsETF options, stock options, commodity options
ETFsAll exchange-traded funds
BondsConvertible bonds, treasury bonds
PeriodsTick, 1m, 5m, 15m, 30m, 1h, 1d, 1w, 1mon
Level2Order-by-order, trade-by-trade (broker dependent)
FinancialBalance sheet, income, cash flow, major indicators

QMT vs miniQMT vs Ptrade

FeatureQMTminiQMTPtrade
Vendor迅投科技迅投科技恒生电子
PythonBuilt-in (restricted)External (any)Built-in (restricted)
GUIFullMinimalFull (web-based)
BacktestingBuilt-inManualBuilt-in
DeploymentLocalLocalBroker server (cloud)
InternetYesYesNo (intranet)

Tips

  • QMT runs on Windows only.
  • Built-in Python version is fixed by QMT — cannot install arbitrary pip packages.
  • For unrestricted Python, use miniQMT mode with xtquant SDK instead.
  • Strategy files are stored in QMT's installation directory.
  • Docs: http://dict.thinktrader.net/freshman/rookie.html
  • VBA interface also available for Excel integration.

Download

ZIP package — ready to use

Skill Info

Creator
coderwpf
Downloads
20
Published
Mar 15, 2026
Updated
Mar 16, 2026