Loading...
Loading...
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.
npx skill4agent add lzwme/finance-quant-skills miniqmtpip install xtquantuserdata_miniQMT安装目录\
├── bin.x64\XtMiniQmt.exe # MiniQMT 主程序
├── userdata_mini\ # 用户数据目录(xttrader 连接路径)
│ ├── xqtrader.ini # 交易配置
│ └── xtdatacenter.ini # 行情配置600000.SH000001.SZrb2405.SF510050.SH| 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 |
nonefrontbackfront_ratioback_ratio| Market | Constant | Market | Constant |
|---|---|---|---|
| Shanghai | | CFFEX | |
| Shenzhen | | SHFE | |
| Beijing Stock Exchange | | CZCE | |
| DCE | | GFEX | |
| Type | Constant | Type | Constant |
|---|---|---|---|
| Stock | | Shanghai-Hong Kong Stock Connect | |
| Futures | | Shenzhen-Hong Kong Stock Connect | |
| Margin | | Futures Option | |
| Stock Option | | - | - |
| 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 |
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()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'
)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}")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()python scripts/market_data.py snapshot --code 600519.SHpython scripts/market_data.py kline --code 600519.SH --period 1d --count 100python scripts/market_data.py tick --code 600519.SH --count 100python scripts/market_data.py full_tick --codes 600519.SH,000001.SZpython scripts/sector_data.py sector_listpython scripts/sector_data.py sector_stocks --sector 半导体python scripts/financial_data.py financial --code 600519.SH --tables Balance,Incomepython scripts/trade.py order --code 600519.SH --type buy --volume 100 --price 1800.0python scripts/trade.py cancel --order_id 12345python scripts/trade.py positionspython scripts/trade.py orderspython scripts/trade.py assetpython scripts/trade.py tradesuserdata_minidownload_history_data2'20240101''20240101000000''FUTURE'get_market_data