跳转至

← 返回接口目录

7709-批量快照

作用

按显式代码列表查询行情快照,适合一次查多个股票的现价、涨跌幅、成交量额、内外盘和盘口。当前实盘 0x054c 响应只稳定确认买一 / 卖一;兼容入口 client.get_quote() 会额外用 0x0547 首次刷新补齐五档盘口。

项目 内容
主要调用 · 基础快照 client.quotes.get_snapshots(codes)
旧版兼容 · 完整行情 client.get_quote(codes)
主要调用 · 五档盘口 client.quotes.get_depth(codes)
便捷调用 · 五档盘口 client.get_quote_depth(codes)
底层接口 基础快照为 0x054c;完整行情和五档盘口还使用 0x0547
返回模型 list[QuoteSnapshot] / QuoteRefreshPage

这个方法按给定代码列表返回当前行情快照。涨幅榜、成交额榜这类服务端排序列表使用 7709-分类行情.md

0x05470x053e 的区别

0x054c 的核心定位是无游标的一次性基础快照,用于建立一批代码的当前行情基线。

  • 它不是 0x05470x0547 带每只代码的刷新游标,首次刷新可返回完整五档,之后用于持续更新。
  • 它不是 0x053e0x053e 是旧版完整快照,一次返回五档、交易状态和旧版尾部原始字段。
  • client.get_quote() 会先调用 0x054c,再用首次 0x0547 刷新补齐五档;0x053e 不参与这个组合。

示例

from eltdx import TdxClient

with TdxClient(timeout=3) as client:
    quotes = client.quotes.get_snapshots(["sz000001", "sh600000"])
    quote = client.get_quote("sz000001")[0]
    depth = client.get_quote_depth("sz000001")
    print(quote.last_price, quote.change_pct)

单代码和多代码都可以传:

one = client.get_quote("sz000001")[0]
many = client.get_quote(["sz000001", "sh600000", "bj920856"])

参数

参数 含义
codes 单个代码或代码列表,支持 sz000001000001 这类写法;没有市场前缀时会按代码段补全

client.quotes.get_snapshots() 是直接调用一次 0x054c,盘口只返回已确认的一档。client.get_quote() 是便捷方法,会按客户端 batch_size 自动拆批,默认最多 80 个代码一批,并用 0x0547 补齐五档盘口。

解析字段

QuoteSnapshot 字段 含义
exchange 市场前缀,sz / sh / bj
market_id 市场编号,0=sz1=sh2=bj
code 六位代码
full_code 完整代码,exchange + code
active1 活跃序号 / 状态序号,原样保留
last_price 最新价 / 现价
pre_close_price 昨收价
open_price 今开价
high_price 最高价
low_price 最低价
time_raw 行情时间原始值
unknown_after_time_raw 时间后保留字段,原样保留
total_hand 总成交量,单位手
current_hand 现手
amount 成交额
amount_raw 成交额 compact-float 原始值
inside_dish 内盘,单位手
outer_disc 外盘,单位手
unknown_after_outer_raw 外盘后保留字段,原样保留
open_amount_raw 开盘金额原始值
open_amount_yuan 开盘金额,单位元
buy_levels / sell_levels client.quotes.get_snapshots() 为买一 / 卖一;client.get_quote() 会补齐买一到买五 / 卖一到卖五
tail_raw 尾部扩展原始字段

buy_levels / sell_levels 单档是 QuoteLevel

QuoteLevel 字段 含义
price 档位价格
volume 档位挂单量,单位手
price_delta_raw 相对现价的价格差分原始值

派生字段

字段 计算方式
change last_price - pre_close_price
change_pct change / pre_close_price * 100
sum_buy_vol 五档买量合计
sum_sell_vol 五档卖量合计

使用建议

场景 建议
查一批指定股票当前行情 client.get_quote([...])
查一个股票 client.get_quote("sz000001")[0]
只查完整五档盘口 client.get_quote_depth(...) / client.quotes.get_depth(...)
查涨幅榜 / 成交额榜 client.quotes.list_by_category()
实时连续刷新可见代码 先用快照初始化,再配合 client.quotes.refresh()

0x054c 返回的是当前行情快照,不包含分时曲线、成交明细、K 线历史。那些数据分别用分时、成交明细和 K 线方法取。