miniqmt
Original:🇨🇳 Chinese
Translated
5 scriptsChecked / no sensitive code detected
MiniQMT Xuntou Quantitative Trading Interface, based on the XtQuant Python library, supports market data acquisition (K-line, tick data, financial data, etc.) and trading operations (order placement, order cancellation, querying assets/orders/positions) for A-shares, futures, and options. It is used when users need to obtain real-time/historical market data from MiniQMT, conduct quantitative trading, or perform backtesting.
21installs
Added on
NPX Install
npx skill4agent add lzwme/finance-quant-skills miniqmtTags
Translated version includes tags in frontmatterSKILL.md Content (Chinese)
View Translation Comparison →MiniQMT Quantitative Trading Skill
Task Objectives
- This Skill is used to: connect to the MiniQMT client via the XtQuant library, obtain market data for A-shares, futures, and options, and execute quantitative trading operations
- Capabilities include:
- Market Module (xtdata): K-line data, tick data, real-time market subscription, financial data, sector classification, ETF information, IPO subscription, trading calendar
- Trading Module (xttrader): Stock/futures/options order placement, order cancellation, asset/order/position query, fund transfer, margin trading, securities lending
- Trigger conditions: Used when users mention miniqmt, xtquant, Xuntou, market data acquisition, quantitative trading, or order placement
Preparations
MiniQMT Environment Requirements
- Client Installation: Need to install Xuntou Extreme Speed Trading Terminal and start MiniQMT (supports simulation/live trading)
- Python Library:
pip install xtquant - Path Configuration: The path under the MiniQMT installation directory is used for xttrader connection
userdata_mini
Directory Structure
QMT安装目录\
├── bin.x64\XtMiniQmt.exe # MiniQMT 主程序
├── userdata_mini\ # 用户数据目录(xttrader 连接路径)
│ ├── xqtrader.ini # 交易配置
│ └── xtdatacenter.ini # 行情配置Core Concepts
Security Code Format
- Stocks: 6-digit number + market suffix, e.g., (Shanghai),
600000.SH(Shenzhen)000001.SZ - Futures: Product code + contract month, e.g., (Rebar)
rb2405.SF - Options: Underlying code + exercise month, e.g., (SSE 50 ETF Option)
510050.SH
Period Type (period)
| Period | Description | Period | Description |
|---|---|---|---|
| Tick data | | Quarterly line |
| 1-minute line | | Semi-annual line |
| 5-minute line | | Annual line |
| 15-minute line | | Weekly line |
| 30-minute line | | Daily line |
| 1-hour line | | Monthly line |
Dividend Adjustment Type (dividend_type)
- - No adjustment
none - - Forward adjustment
front - - Backward adjustment
back - - Equal ratio forward adjustment
front_ratio - - Equal ratio backward adjustment
back_ratio
Trading Market (market)
| Market | Constant | Market | Constant |
|---|---|---|---|
| Shanghai | | CFFEX | |
| Shenzhen | | SHFE | |
| Beijing Stock Exchange | | CZCE | |
| DCE | | GFEX | |
Account Type (account_type)
| Type | Constant | Type | Constant |
|---|---|---|---|
| Stock | | Shanghai-Hong Kong Stock Connect | |
| Futures | | Shenzhen-Hong Kong Stock Connect | |
| Margin | | Futures Option | |
| Stock Option | | - | - |
Operation Steps
- Confirm Requirements — Identify whether it is market data acquisition or trading operation
- Select Module — Use xtdata for market data, xttrader for trading
- Call Script — Select the corresponding script based on data type
- Parse Results — The agent analyzes the returned JSON format data
Intent Recognition Mapping Examples
| User Query | Corresponding Function | Calling Method |
|---|---|---|
| "贵州茅台实时股价" | Real-time market snapshot | xtdata.get_full_tick |
| "平安银行K线数据" | K-line data | xtdata.get_market_data |
| "招商银行财务指标" | Financial statements | xtdata.get_financial_data |
| "半导体板块成分股" | Sector constituent stocks | xtdata.get_stock_list_in_sector |
| "今日可转债信息" | ETF/convertible bond data | xtdata.get_cb_info |
| "新股申购" | IPO information | xtdata.get_ipo_info |
| "下单买入平安银行" | Trading order placement | xttrader.order_stock |
| "查询持仓" | Position query | xttrader.query_stock_positions |
| "撤单" | Order cancellation | xttrader.cancel_order_stock |
Usage Examples
Example 1: Get Real-time Stock Market Data
python
import xtdata
# 获取全推行情快照
ticks = xtdata.get_full_tick(['600519.SH', '000001.SZ'])
# 订阅单股实时行情
def on_data(datas):
for code in datas:
print(code, datas[code])
xtdata.subscribe_quote('600519.SH', period='tick', callback=on_data)
xtdata.run()Example 2: Get Historical K-line Data
python
import xtdata
# 下载历史K线数据
xtdata.download_history_data2(['600519.SH'], period='1d', start_time='')
# 获取K线数据
data = xtdata.get_market_data(
field_list=['open', 'high', 'low', 'close', 'volume'],
stock_list=['600519.SH'],
period='1d',
start_time='20240101',
end_time='',
count=100,
dividend_type='front'
)Example 3: Trading Order Placement
python
from xtquant.xttrader import XtQuantTrader, XtQuantTraderCallback
from xtquant.xttype import StockAccount
from xtquant import xtconstant
# 配置路径和会话
path = 'D:\\迅投极速交易终端\\userdata_mini'
session_id = 123456
xt_trader = XtQuantTrader(path, session_id)
# 创建账号对象
acc = StockAccount('1000000365') # 替换为实际账号
# 连接交易
xt_trader.start()
connect_result = xt_trader.connect()
subscribe_result = xt_trader.subscribe(acc)
# 下单买入
order_id = xt_trader.order_stock(
acc,
'600519.SH',
xtconstant.STOCK_BUY,
100, # 100股
xtconstant.FIX_PRICE,
1800.0, # 价格
'strategy1',
'remark'
)
# 查询资产
asset = xt_trader.query_stock_asset(acc)
print(f"可用资金: {asset.cash}")Example 4: Subscribe to Market Data and Process in Real-time
python
import xtdata
def on_tick_data(datas):
for code in datas:
tick = datas[code]
print(f"{code}: 现价={tick['lastPrice']}, 成交量={tick['volume']}")
# 订阅多只股票
xtdata.subscribe_whole_quote(['SH', 'SZ'], callback=on_tick_data)
xtdata.run()Resource Index
Market Data Scripts
- Market Snapshot:
python scripts/market_data.py snapshot --code 600519.SH - K-line Data:
python scripts/market_data.py kline --code 600519.SH --period 1d --count 100 - Tick Data:
python scripts/market_data.py tick --code 600519.SH --count 100 - Real-time Market:
python scripts/market_data.py full_tick --codes 600519.SH,000001.SZ
Sector and Financial Scripts
- Sector List:
python scripts/sector_data.py sector_list - Sector Constituent Stocks:
python scripts/sector_data.py sector_stocks --sector 半导体 - Financial Data:
python scripts/financial_data.py financial --code 600519.SH --tables Balance,Income
Trading Scripts
- Order Placement:
python scripts/trade.py order --code 600519.SH --type buy --volume 100 --price 1800.0 - Order Cancellation:
python scripts/trade.py cancel --order_id 12345 - Position Query:
python scripts/trade.py positions - Order Query:
python scripts/trade.py orders - Asset Query:
python scripts/trade.py asset - Trade Query:
python scripts/trade.py trades
Reference Documents
- xtdata Market Module API (When to read: Need to check market data interfaces)
- xtdata Market Data Fields and Data Dictionary (When to read: Need to check market data fields and data dictionary)
- xttrader Trading Module API (When to read: Need to check trading interfaces and data structure descriptions)
- Installation and Download Guide (When to read: First-time installation of XtQuant or encountering installation issues)
- FAQs (When to read: Encountering common issues)
- Code Examples (When to read: Need to refer to complete code examples)
- Changelog (When to read: Check version update history)
Notes
Environment Requirements
- Must Run MiniQMT: The xttrader trading module requires the MiniQMT client to run in the background
- Path Configuration: Ensure the path is correct, otherwise the connection will fail
userdata_mini - Market Subscription Limits: It is recommended not to subscribe to more than 50 individual stocks; use full push data when subscribing to more
Data Acquisition Notes
- Data Supplementary Download: Historical data must be downloaded first via
download_history_data2 - Permission Restrictions: Level2 data requires corresponding terminal permissions
- Time Format: K-line time parameters are in the format or
'20240101''20240101000000'
Trading Notes
- Account Format: Use the capital account string directly for stock accounts; specify for futures accounts
'FUTURE' - Order Quantity: Stocks are in "shares", bonds in "sheets", futures in "lots"
- Order ID: A positive integer order_id is returned upon successful order placement; -1 indicates failure
- Asynchronous Operations: Trading operations support both synchronous and asynchronous modes; asynchronous mode requires matching callbacks
Performance Optimization
- Batch Requests: It is recommended to use to obtain data for multiple stocks in batches
get_market_data - Cache Utilization: Subscribed data is automatically cached, no need to subscribe repeatedly
- Thread Safety: xttrader supports multiple strategies, but different session_ids must be used