7709-增量刷新推送队列¶
作用¶
发起一次行情增量刷新请求,并读取 transport 收到的未配对推送帧。
| 项目 | 内容 |
|---|---|
| 五档快捷入口 | client.quotes.get_depth(codes) |
| 行情刷新 | client.quotes.refresh(...) |
| 读取推送 | client.quotes.poll_push(...) |
| 清空队列 | client.quotes.drain_pushes(...) |
| 底层接口 | 0x0547 |
| 返回模型 | QuoteRefreshPage 或推送帧 |
与 0x054c、0x053e 的区别¶
0x0547 的核心定位是按代码和游标刷新行情。首次游标通常为 0,所以返回内容可能看起来像完整快照;后续调用才体现增量刷新语义。
单次请求最多接受 100 个代码。实盘主站对 101 个及以上代码只返回前 100 条,客户端因此在构包前拒绝超限请求,避免调用成功但结果被静默截断。
- 它不是
0x054c:0x054c不带游标,只负责一次性建立基础快照,实盘稳定确认一档盘口。 - 它不是
0x053e:0x053e每次都重新查询旧版完整快照,不支持游标刷新,也不承担推送队列语义。 0x0547返回QuoteRefreshPage / QuoteRefreshRecord;0x053e返回LegacyQuote,两者的二进制布局和解析器不能互换。
示例¶
from eltdx import TdxClient
with TdxClient(timeout=3) as client:
depth = client.quotes.get_depth(["sz000001", "sh600000"])
page = client.quotes.refresh(["sz000001"], cursors={"sz000001": 0})
frame = client.quotes.poll_push(timeout=0.5)
frames = client.quotes.drain_pushes()
解析推送帧:
frame = client.quotes.poll_push(timeout=0.5, parse=True)
frames = client.quotes.drain_pushes(parse=True)
参数¶
| 参数 | 含义 |
|---|---|
codes |
关注代码列表 |
cursors |
每个代码的增量游标,首次通常传 0 |
timeout |
读取推送队列时最多等待多少秒 |
parse |
是否尝试把推送帧解析成业务模型 |
解析字段¶
QuoteRefreshPage 字段 |
含义 |
|---|---|
requested_codes |
请求代码 |
records |
增量行情记录 |
decoded_payload |
解码后的 payload |
raw_payload |
原始 payload |
count |
记录数 |
QuoteRefreshRecord 字段 |
含义 |
|---|---|
exchange / market_id / code / full_code |
市场和代码 |
active |
活跃序号 / 状态序号 |
update_time_raw |
更新时间原始值 |
last_price / last_close_price |
最新价 / 昨收价 |
open_price / high_price / low_price |
今开 / 最高 / 最低 |
status_or_reserved_raw |
状态 / 保留原始字段 |
total_hand / current_hand |
总量 / 现量,单位手 |
amount / amount_raw |
成交额 / 成交额原始值 |
inside_dish / outer_disc |
内盘 / 外盘,单位手 |
unknown_after_outer_raw |
外盘后保留字段 |
open_amount_raw / open_amount_yuan |
开盘金额原始值 / 开盘金额 |
buy_levels / sell_levels |
刷新记录中的盘口字段;首次刷新用于建立实时五档,后续由推送增量更新 |
tail_raw |
尾部原始字段 |
record_hex |
单条记录原始十六进制 |
buy_levels / sell_levels 单档是 QuoteLevel,字段为 price、volume、price_delta_raw。
使用说明¶
| 项目 | 说明 |
|---|---|
refresh() |
主动发一次 0x0547 请求,返回本次增量刷新页;单次最多 100 个代码 |
poll_push() |
从 transport 推送队列取一帧;没有则返回 None |
drain_pushes() |
把当前队列里已有推送帧一次性取完 |
cursors |
每个代码的增量游标;首次通常传 0 |
client.quotes.get_depth() |
原生 0x0547 五档快捷入口,首次刷新建立基线;后续可用 refresh() / 推送持续更新 |
| 初始化 | 通常先用 7709-批量快照.md 拉初始行情,再用增量刷新 |
真实返回样本¶
真实返回 JSON · QuoteRefreshPage(1 条节选)
真实采样;主动 get_depth() 返回一条刷新记录,采样时推送队列为空,因此 poll_push() 为 null。
{
"requested_codes": ["sz000001"],
"records": [
{
"exchange": "sz",
"code": "000001",
"active": 4712,
"update_time_raw": 150545,
"last_price": 11.1,
"last_close_price": 11.11,
"open_price": 11.2,
"high_price": 11.22,
"low_price": 11.07,
"total_hand": 929043,
"amount": 1031951488.0,
"buy_levels": [
{"price": 11.1, "volume": 362, "price_delta_raw": 0}
]
}
],
"poll_push_when_empty": null
}