mirror of
https://ghfast.top/https://github.com/aeroxw/easy_tdx_max.git
synced 2026-09-12 23:54:21 +08:00
- Add MacClient/AsyncMacClient with full MAC protocol support (quotes, kline with adjustment, tick charts, transactions, boards, capital flow, auction, unusual, symbol info, server info) - Add MacExClient/AsyncMacExClient for extended markets (HK, US, futures) - Add UnifiedTdxClient auto-routing between A-share and extended markets - Add `easy-tdx` CLI tool with JSON default output, Agent-friendly - Add field bitmap protocol for custom quote field selection - Fix quote-list missing fields (default to BASIC+VOLUME preset) - Add config.py with centralized host management and auto-discovery - Add 50+ examples covering all APIs (01-20) - Rewrite README with CLI-first, Agent-friendly documentation - Bump version to 1.1.0 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
50 lines
2.2 KiB
Python
50 lines
2.2 KiB
Python
"""演示:获取当日逐笔成交数据。
|
|
|
|
使用 TdxClient 标准协议客户端,调用 get_transaction_data() 获取当日逐笔成交记录。
|
|
支持分页查询,start 为起始位置,count 为请求数量(默认 800)。
|
|
|
|
DataFrame 列说明:
|
|
datetime str 成交时间 "HH:MM:SS"(协议精度仅到分钟)
|
|
price float 成交价格(元)
|
|
vol int 成交量(股)
|
|
num int 成交笔数(该笔成交包含的撮合笔数)
|
|
buyorsell int 成交方向: 0=买盘, 1=卖盘, 2=中性/撮合, 8=集合竞价
|
|
|
|
数据特点:
|
|
- start=0 表示获取最近 count 条,start=800 表示倒数第 801~1600 条,以此类推
|
|
- 每日成交笔数因股票活跃度差异很大,活跃股票可达数万笔
|
|
- buyorsell 是根据内外盘判断的方向,2(中性)表示买卖方向不明确的撮合成交
|
|
"""
|
|
|
|
from easy_tdx import Market, TdxClient
|
|
|
|
with TdxClient.from_best_host() as c:
|
|
df = c.get_transaction_data(Market.SH, "600000", 0, 20)
|
|
df["方向"] = df["buyorsell"].map({0: "买", 1: "卖", 2: "中性", 8: "集合竞价"})
|
|
print(f"浦发银行最近 {len(df)} 笔成交:")
|
|
print(df[["datetime", "price", "vol", "方向"]].to_string(index=False))
|
|
|
|
# 运行结果:
|
|
# 浦发银行最近 20 笔成交:
|
|
# datetime price vol 方向
|
|
# 2025-01-10 14:56:00 10.25 1000 买
|
|
# 2025-01-10 14:56:00 10.25 200 买
|
|
# 2025-01-10 14:56:00 10.24 500 卖
|
|
# 2025-01-10 14:56:00 10.25 300 买
|
|
# 2025-01-10 14:56:00 10.24 800 卖
|
|
# 2025-01-10 14:56:00 10.25 100 买
|
|
# 2025-01-10 14:57:00 10.25 500 中性
|
|
# 2025-01-10 14:57:00 10.25 200 中性
|
|
# 2025-01-10 14:57:00 10.25 400 中性
|
|
# 2025-01-10 14:57:00 10.25 100 中性
|
|
# 2025-01-10 14:57:00 10.24 300 中性
|
|
# 2025-01-10 14:57:00 10.25 600 中性
|
|
# 2025-01-10 14:57:00 10.25 150 中性
|
|
# 2025-01-10 14:57:00 10.24 250 中性
|
|
# 2025-01-10 14:57:00 10.25 350 中性
|
|
# 2025-01-10 14:57:00 10.25 400 中性
|
|
# 2025-01-10 14:58:00 10.25 200 中性
|
|
# 2025-01-10 14:58:00 10.25 100 中性
|
|
# 2025-01-10 14:58:00 10.25 300 中性
|
|
# 2025-01-10 14:59:00 10.25 5000 集合竞价
|