miniqmt-skill
A quantitative trading library for connecting to MiniQMT terminals to automate market data analysis and trade execution.
Install
mkdir -p .claude/skills/miniqmt-skill && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/15406" && unzip -o skill.zip -d .claude/skills/miniqmt-skill && rm skill.zipInstalls to .claude/skills/miniqmt-skill
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
MiniQMT量化交易开发技能,基于迅投XtQuant库提供行情数据获取(xtdata)和交易执行(xttrader)功能。用于开发股票、期货、期权等量化交易策略,支持历史/实时行情数据下载、K线/分笔数据获取、财务数据查询、自动下单/撤单、持仓查询、资产查询等。适用于需要连接MiniQMT客户端进行量化交易的场景。Key capabilities
- →Download historical market data for specific stocks and periods
- →Get real-time market data including open, high, low, close, and volume
- →Execute stock orders for buying and selling
- →Query current stock positions and assets
- →Retrieve financial data for analysis
- →Subscribe to real-time quotes
How it works
The skill uses the XtQuant Python library to interact with the MiniQMT client, providing functions for market data retrieval and trade execution.
Inputs & outputs
When to use miniqmt-skill
- →Backtest trading strategies
- →Automate stock orders
- →Fetch historical K-line data
- →Query asset and position status
About this skill
MiniQMT 量化交易开发指南
概述
MiniQMT是基于迅投QMT的极简量化交易终端,通过XtQuant Python库提供行情和交易API。
运行依赖:
- 已安装MiniQMT客户端并启动
- Python 3.6-3.12 (64位)
- 安装xtquant库
核心模块:
xtdata- 行情数据模块:K线、分笔、财务数据、合约信息等xttrader- 交易模块:下单、撤单、查询、主推消息
快速开始
1. 行情数据获取
from xtquant import xtdata
# 下载历史数据(必须先下载才能获取)
xtdata.download_history_data('600000.SH', period='1d', start_time='20240101')
# 获取行情数据
data = xtdata.get_market_data(
field_list=['open', 'high', 'low', 'close', 'volume'],
stock_list=['600000.SH'],
period='1d',
start_time='20240101',
count=-1
)
2. 交易功能
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') # 资金账号
# 注册回调并启动
callback = MyXtQuantTraderCallback()
xt_trader.register_callback(callback)
xt_trader.start()
xt_trader.connect()
xt_trader.subscribe(acc)
# 下单
order_id = xt_trader.order_stock(
acc, '600000.SH', xtconstant.STOCK_BUY,
100, xtconstant.FIX_PRICE, 10.5
)
详细功能参考
行情模块 (xtdata)
主要功能:
- 历史K线数据下载/获取 (
download_history_data,get_market_data) - 实时行情订阅 (
subscribe_quote,subscribe_whole_quote) - 分笔数据获取 (
get_full_tick) - 财务数据下载/获取 (
download_financial_data,get_financial_data) - 板块/行业数据 (
download_sector_data,get_stock_list_in_sector) - 合约基础信息 (
get_instrument_detail)
交易模块 (xttrader)
主要功能:
- 同步/异步下单 (
order_stock,order_stock_async) - 撤单 (
cancel_order_stock) - 资产查询 (
query_stock_asset) - 持仓查询 (
query_stock_positions,query_stock_position) - 委托查询 (
query_stock_orders,query_stock_order) - 成交查询 (
query_stock_trades) - 主推消息回调 (
on_stock_order,on_stock_trade等)
常用常量
委托类型 (xtconstant)
# 股票
STOCK_BUY = 23 # 买入
STOCK_SELL = 24 # 卖出
# 期货
FUTURE_OPEN_LONG = 0 # 开多
FUTURE_CLOSE_LONG_TODAY = 1 # 平今多
FUTURE_CLOSE_LONG_HISTORY = 2 # 平昨多
FUTURE_OPEN_SHORT = 3 # 开空
FUTURE_CLOSE_SHORT_TODAY = 4 # 平今空
FUTURE_CLOSE_SHORT_HISTORY = 5 # 平昨空
报价类型
FIX_PRICE = 11 # 指定价
LATEST_PRICE = 5 # 最新价
委托状态
ORDER_UNREPORTED = 48 # 未报
ORDER_REPORTED = 50 # 已报
ORDER_PART_SUCC = 55 # 部成
ORDER_SUCCEEDED = 56 # 已成
ORDER_CANCELED = 54 # 已撤
ORDER_JUNK = 57 # 废单
示例代码
详见 scripts/ 目录:
market_data_demo.py- 行情数据获取示例trading_demo.py- 交易功能示例data_download.py- 批量数据下载示例
注意事项
- 数据下载:使用
get_market_data前必须先调用download_history_data下载数据到本地 - 订阅限制:单股订阅数量建议不超过50,更多请使用全推订阅
- 路径配置:券商版指向
userdata_mini,投研版指向userdata - session_id:不同策略使用不同的会话编号
- 回调处理:交易回调中调用同步查询需开启
set_relaxed_response_order_enabled
数据字典速查
合约代码格式
- 股票:
000001.SZ,600000.SH - 期货:
rb2405.SF,IF2403.IF - 期权:
510050.SH(ETF期权),sc2403C465.INE(商品期权)
周期类型
tick- 分笔数据1m,5m,15m,30m,1h- 分钟/小时线1d,1w,1mon,1q,1hy,1y- 日/周/月/季/半年/年线
除权方式
none- 不复权front- 前复权back- 后复权front_ratio- 等比前复权back_ratio- 等比后复权
When not to use it
- →When not connected to a MiniQMT client
- →When developing trading strategies for platforms other than MiniQMT
- →When the required Python version is outside 3.6-3.12
Prerequisites
Limitations
- →Single stock subscription quantity is suggested not to exceed 50
- →Historical data must be downloaded before it can be retrieved
- →Trading callbacks require enabling set_relaxed_response_order_enabled for synchronous queries
How it compares
This skill provides a direct Python API for MiniQMT, enabling programmatic control over trading and data fetching compared to manual client operation.
Compared to similar skills
miniqmt-skill side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| miniqmt-skill (this skill) | 0 | 6mo | Review | Intermediate |
| finance-manager | 12 | 9mo | Review | Intermediate |
| data-engineering-data-pipeline | 4 | 4mo | No flags | Advanced |
| add-vault-note | 1 | 5mo | No flags | Intermediate |
Try saying
Example prompts that trigger this skill in your AI assistant.
You might also like
finance-manager
ailabs-393
Comprehensive personal finance management system for analyzing transaction data, generating insights, creating visualizations, and providing actionable financial recommendations. Use when users need to analyze spending patterns, track budgets, visualize financial data, extract transactions from PDFs, calculate savings rates, identify spending trends, generate financial reports, or receive personalized budget recommendations. Triggers include requests like "analyze my finances", "track my spending", "create a financial report", "extract transactions from PDF", "visualize my budget", "where is my money going", "financial insights", "spending breakdown", or any finance-related analysis tasks.
data-engineering-data-pipeline
sickn33
You are a data pipeline architecture expert specializing in scalable, reliable, and cost-effective data pipelines for batch and streaming data processing.
add-vault-note
tradingstrategy-ai
Add a note to specific vault
df-basic-stats
qmakescl
>
add-etf
michaellaret7
Add an ETF to the database with proper classification. Handles web research, DB format matching, confirmation, and execution.
portfoliosyncing
AojdevStudio
Import and sync broker CSV portfolio data to Google Sheets DataHub. Supports multiple brokers (Fidelity, Schwab, Vanguard, etc.). USE WHEN user mentions import broker data OR sync portfolio OR update positions OR CSV import OR portfolio-sync OR working with Portfolio_Positions CSVs. Handles position updates, SPAXX/margin validation, safety checks, and formula protection.