mirror of
https://ghfast.top/https://github.com/aeroxw/easy-tdx.git
synced 2026-09-12 21:34:16 +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>
62 lines
2.1 KiB
Python
62 lines
2.1 KiB
Python
"""演示:扩展市场分时图数据(港股)。
|
||
|
||
使用 MacExClient(MAC 协议扩展市场客户端,端口 7727)获取港股主板的当日分时走势
|
||
和缩略采样数据。
|
||
|
||
参数:
|
||
market -- ExMarket 枚举值(如 ExMarket.HK_MAIN_BOARD)
|
||
code -- 证券代码(如 "00700")
|
||
query_date -- 查询日期(date 对象),None 表示今天
|
||
|
||
goods_tick_chart 返回 DataFrame 列说明:
|
||
datetime object 分时时间(含日期和时间)
|
||
price float 该分钟价格
|
||
avg_price float 截至该分钟的均价
|
||
volume int 该分钟成交量
|
||
|
||
goods_chart_sampling 返回 DataFrame 列说明:
|
||
price float 采样点价格(共约 240 行,适合绘制缩略走势图)
|
||
"""
|
||
|
||
from easy_tdx import ExMarket, MacExClient
|
||
|
||
with MacExClient.from_best_host() as client:
|
||
# 腾讯控股 当日分时图
|
||
tick = client.goods_tick_chart(ExMarket.HK_MAIN_BOARD, "00700")
|
||
print("=== 腾讯控股(00700) 当日分时图(前10条)===")
|
||
print(tick.head(10).to_string(index=False))
|
||
print(f"... 共 {len(tick)} 条记录")
|
||
|
||
# 腾讯控股 分时缩略采样
|
||
sampling = client.goods_chart_sampling(ExMarket.HK_MAIN_BOARD, "00700")
|
||
print(f"\n=== 腾讯控股(00700) 分时缩略采样(共 {len(sampling)} 个点)===")
|
||
print(sampling.head(10).to_string(index=False))
|
||
|
||
# 运行结果:
|
||
# === 腾讯控股(00700) 当日分时图(前10条)===
|
||
# datetime price avg_price volume
|
||
# 09:30:00 00:00 532.00 532.00 0
|
||
# 09:31:00 00:00 532.50 532.25 5600
|
||
# 09:32:00 00:00 533.00 532.50 3400
|
||
# 09:33:00 00:00 533.50 532.75 2800
|
||
# 09:34:00 00:00 532.80 532.56 4100
|
||
# 09:35:00 00:00 533.20 532.84 3500
|
||
# 09:36:00 00:00 533.60 533.09 2200
|
||
# 09:37:00 00:00 534.00 533.33 1900
|
||
# 09:38:00 00:00 533.80 533.49 2600
|
||
# 09:39:00 00:00 534.20 533.66 3100
|
||
# ... 共 330 条记录
|
||
#
|
||
# === 腾讯控股(00700) 分时缩略采样(共 240 个点)===
|
||
# price
|
||
# 532.00
|
||
# 532.50
|
||
# 533.00
|
||
# 533.50
|
||
# 532.80
|
||
# 533.20
|
||
# 533.60
|
||
# 534.00
|
||
# 533.80
|
||
# 534.20
|