QMT Tick 数据结构是实时行情推送和历史 Tick 数据查询中使用的标准数据格式,包含最新价、开盘价、最高价、最低价、成交量、成交额以及多档买卖盘等字段。该结构在 get_full_ticksubscribe_quote 回调以及 get_market_data_ex(period='tick')中使用。

QMT Tick 数据基本字段

【事实】 以下为 Tick 数据中的基本行情字段:

字段名 类型 含义 示例值
last_price float 最新成交价 10.52
open float 今日开盘价 10.50
high float 今日最高价 10.55
low float 今日最低价 10.48
last_volume int 最新一笔成交量(股) 100
volume int 今日累计成交量(股) 5000000
amount float 今日累计成交额(元) 52600000.0
stock_code str 证券代码 '600000.SH'
time int 时间戳,格式 YYYYMMDDHHMMSS 20240104093015
pre_close float 昨日收盘价 10.45

【解释】 - last_price 是最新一笔成交的价格,非买一价或卖一价。 - last_volume 是最新一笔成交的量,不是累计量。累计量通过 volume 字段获取。 - pre_close 用于计算涨跌幅:(last_price - pre_close) / pre_close * 100。 - time 为整数类型的时间戳,格式为 年月日时分秒

QMT Tick 数据买卖盘字段

【事实】 以下为 Tick 数据中的买卖盘字段,均为列表类型,索引 0 对应买一/卖一,索引 9 对应买十/卖十:

字段名 类型 含义 示例值
bid_price list[float] 买价列表(买一至买十) [10.51, 10.50, 10.49, 10.48, 10.47, 0, 0, 0, 0, 0]
ask_price list[float] 卖价列表(卖一至卖十) [10.52, 10.53, 10.54, 10.55, 10.56, 0, 0, 0, 0, 0]
bid_volume list[int] 买量列表(买一至买十) [500, 800, 1200, 2000, 3000, 0, 0, 0, 0, 0]
ask_volume list[int] 卖量列表(卖一至卖十) [300, 600, 1000, 1500, 2500, 0, 0, 0, 0, 0]

【事实】 买卖盘档位数与行情权限的关系:

行情权限 可用档位数 列表有效长度
Level-1 5 档 索引 0~4 有效,5~9 为 0
Level-2 10 档 索引 0~9 均有效

【解释】 - bid_pricebid_volume 描述买方挂单:bid_price[0] 是买一价(最高买价),bid_volume[0] 是买一量。 - ask_priceask_volume 描述卖方挂单:ask_price[0] 是卖一价(最低卖价),ask_volume[0] 是卖一量。 - 买卖价差 = ask_price[0] - bid_price[0]。 - 未使用的档位(超出行情权限的档位)价格为 0,数量为 0。

【建议】 访问买卖盘数据前应检查列表长度和价格是否为 0,避免索引越界或使用无效数据。

QMT Tick 数据扩展字段

【事实】 以下为部分客户端版本中可能提供的扩展字段:

字段名 类型 含义 说明
avg_price float 今日均价 成交额 / 成交量
upper_limit float 涨停价 当日涨停价格
lower_limit float 跌停价 当日跌停价格
num_trades int 成交笔数 今日累计成交笔数
iopv float ETF 参考净值 仅 ETF 适用
bid_count list[int] 买盘订单数列表 Level-2 独有
ask_count list[int] 卖盘订单数列表 Level-2 独有

【建议】 扩展字段的可用性以当前客户端版本和行情权限为准,使用前应检查字段是否存在。

QMT Tick 数据字段速查表

【事实】 全部字段汇总表:

字段名 类型 含义 Level-1 Level-2
last_price float 最新成交价 可用 可用
open float 开盘价 可用 可用
high float 最高价 可用 可用
low float 最低价 可用 可用
pre_close float 昨收价 可用 可用
last_volume int 最新成交量 可用 可用
volume int 累计成交量 可用 可用
amount float 累计成交额 可用 可用
stock_code str 证券代码 可用 可用
time int 时间戳 可用 可用
bid_price[0-4] list[float] 买价 1-5 档 可用 可用
ask_price[0-4] list[float] 卖价 1-5 档 可用 可用
bid_volume[0-4] list[int] 买量 1-5 档 可用 可用
ask_volume[0-4] list[int] 卖量 1-5 档 可用 可用
bid_price[5-9] list[float] 买价 6-10 档 不可用 可用
ask_price[5-9] list[float] 卖价 6-10 档 不可用 可用
bid_volume[5-9] list[int] 买量 6-10 档 不可用 可用
ask_volume[5-9] list[int] 卖量 6-10 档 不可用 可用
upper_limit float 涨停价 可用 可用
lower_limit float 跌停价 可用 可用
avg_price float 均价 可用 可用
num_trades int 成交笔数 不可用 可用
iopv float ETF 参考净值 可用 可用
bid_count[0-9] list[int] 买盘订单数 不可用 可用
ask_count[0-9] list[int] 卖盘订单数 不可用 可用

QMT Tick 数据使用示例

从 get_full_tick 获取 Tick 数据

# -*- coding: utf-8 -*- def handlebar(ContextInfo): if not ContextInfo.is_last_bar(): return tick_data = ContextInfo.get_full_tick('600000.SH') tick = tick_data.get('600000.SH') if tick and tick['last_price'] > 0: # 基本字段 print(f'最新价: {tick["last_price"]}') print(f'开盘价: {tick["open"]}') print(f'最高价: {tick["high"]}') print(f'最低价: {tick["low"]}') print(f'昨收价: {tick.get("pre_close", 0)}') # 涨跌幅计算 pre_close = tick.get('pre_close', 0) if pre_close > 0: change_ratio = (tick['last_price'] - pre_close) / pre_close * 100 print(f'涨跌幅: {change_ratio:.2f}%') # 买卖盘 bid_price = tick.get('bid_price', []) ask_price = tick.get('ask_price', []) bid_volume = tick.get('bid_volume', []) ask_volume = tick.get('ask_volume', []) if bid_price and ask_price and bid_price[0] > 0 and ask_price[0] > 0: spread = ask_price[0] - bid_price[0] print(f'买一: {bid_price[0]} x {bid_volume[0]}') print(f'卖一: {ask_price[0]} x {ask_volume[0]}') print(f'买卖价差: {spread}') # 涨跌停价 upper = tick.get('upper_limit', 0) lower = tick.get('lower_limit', 0) if upper > 0: print(f'涨停价: {upper}, 跌停价: {lower}')

从 subscribe_quote 回调获取 Tick 数据

def init(ContextInfo): ContextInfo.subscribe_quote('600000.SH', 'tick', on_tick) def on_tick(ContextInfo, tick_data): """Tick 回调:记录行情快照""" last_price = tick_data.get('last_price', 0) volume = tick_data.get('last_volume', 0) amount = tick_data.get('amount', 0) # 记录到自定义属性 if not hasattr(ContextInfo, 'tick_history'): ContextInfo.tick_history = [] ContextInfo.tick_history.append({ 'time': tick_data.get('time', 0), 'price': last_price, 'volume': volume, 'amount': amount }) # 保留最近 100 条 if len(ContextInfo.tick_history) > 100: ContextInfo.tick_history = ContextInfo.tick_history[-100:]

从 get_market_data_ex 获取历史 Tick 数据

def handlebar(ContextInfo): if not ContextInfo.is_last_bar(): return # 获取历史 Tick 数据 data = ContextInfo.get_market_data_ex( field_list=[], stock_list=['600000.SH'], period='tick', start_time='20240104', end_time='20240104', count=-1, dividend_type='none', fill_data=False ) df = data.get('600000.SH') if df is not None and len(df) > 0: print(f'获取到 {len(df)} 条 Tick 数据') print(df.head(10))

QMT Tick 数据注意事项

【事实】 使用 Tick 数据时需注意:

注意项 说明
行情权限 买卖盘档位数取决于 Level-1 / Level-2 权限
数据量 Tick 数据量远大于 K 线数据,需注意内存和存储
时间精度 Tick 时间戳精度为秒,部分版本支持毫秒
停牌处理 停牌证券的 Tick 数据中价格为 0 或保持上一有效值
数据延迟 实盘 Tick 数据可能有微小延迟,取决于网络和行情源

【建议】 1. 访问买卖盘列表前检查列表是否为空以及价格是否为 0 2. 处理 Tick 数据时注意数据量,避免内存溢出 3. 回测中获取历史 Tick 数据需提前下载 4. Tick 数据的时间戳可能存在重复(同一秒内多笔成交),不应假设时间戳唯一

QMT Tick 数据来源与更新时间

【事实】 本页面内容基于 QMT 官方文档整理。

项目
数据来源 QMT 官方文档
更新时间 2026-08-04
验证时间 2026-08-04
适用版本 以当前客户端版本为准