ClawKit Logo
ClawKitReliability Toolkit
Back to Registry
Official Verified

xtquant

XtQuant QMT Python SDK - 集成行情数据(xtdata)和交易接口(xttrade),支持A股、期货、期权等中国证券市场。

skill-install — Terminal

Install via CLI (Recommended)

clawhub install openclaw/skills/skills/coderwpf/xtquant
Or

XtQuant(迅投QMT Python SDK)

XtQuant is the Python SDK for the QMT/miniQMT quantitative trading platform, developed by ThinkTrader (XunTou Technology). It contains two core modules:

  • xtdata — Market Data Module: real-time quotes, historical K-lines, tick data, Level 2 data, financial data, sector management
  • xttrade — Trading Module: order placement, position/order queries, account management, margin trading, futures/options, smart algorithms

⚠️ Requires miniQMT or QMT client running on Windows. XtQuant connects to the QMT process via local TCP. You need QMT/miniQMT access enabled by your broker.

安装

pip install xtquant

You can also download from the official website: http://dict.thinktrader.net/nativeApi/download_xtquant.html

架构概述

Your Python script (any IDE, any Python version)
    ↓ (xtquant SDK, pip install)
    ├── xtdata  → miniQMT (market data service, TCP connection)
    └── xttrade → miniQMT (trading service, TCP connection)
         ↓
    Broker trading system

核心模块参考

ModuleImportPurpose
xtdatafrom xtquant import xtdataMarket data: K-lines, tick, Level 2, financials, sectors
xttraderfrom xtquant.xttrader import XtQuantTraderTrading: order placement, queries, callbacks
xtconstantfrom xtquant import xtconstantConstants: order types, price types, market codes
xttypefrom xtquant.xttype import StockAccountAccount types: STOCK, CREDIT, FUTURE

快速入门 — 行情数据

from xtquant import xtdata

# Connect to local miniQMT (default: localhost)
xtdata.connect()

# Download historical K-line data (must download to local cache before first access)
xtdata.download_history_data('000001.SZ', '1d', start_time='20240101', end_time='20240630')

# Get local K-line data (returns a dict of DataFrames keyed by stock code)
data = xtdata.get_market_data_ex(
    [],                    # field_list, empty list means all fields
    ['000001.SZ'],         # stock_list, list of stock codes
    period='1d',
    start_time='20240101',
    end_time='20240630',
    dividend_type='front'  # 复权类型: none (unadjusted), front (forward-adjusted), back (backward-adjusted), front_ratio (proportional forward), back_ratio (proportional backward)
)
print(data['000001.SZ'])

实时行情订阅

def on_data(datas):
    """Quote data callback function, receives pushed real-time data"""
    for stock_code, data in datas.items():
        print(stock_code, data)

# Subscribe to tick data for a single stock
xtdata.subscribe_quote('000001.SZ', period='tick', callback=on_data)

# Subscribe to full-market quote push
xtdata.subscribe_whole_quote(['SH', 'SZ'], callback=on_data)

xtdata.run()  # Block the current thread, continuously receiving callback data

财务数据

Metadata

Author@coderwpf
Stars3409
Views0
Updated2026-03-25
View Author Profile
AI Skill Finder

Not sure this is the right skill?

Describe what you want to build — we'll match you to the best skill from 16,000+ options.

Find the right skill
Add to Configuration

Paste this into your clawhub.json to enable this plugin.

{
  "plugins": {
    "official-coderwpf-xtquant": {
      "enabled": true,
      "auto_update": true
    }
  }
}
Safety NoteClawKit audits metadata but not runtime behavior. Use with caution.