Files
easy-tdx/examples/15_mac_board/belong_board.py
T
GitHubandClaude Opus 4.7 4820b4a049 feat: v1.1.0 - MAC protocol, CLI tool, extended markets, unified client
- 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>
2026-05-22 22:44:45 +08:00

43 lines
1.7 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""演示:个股所属板块。
通过 MacClient 的 get_belong_board() 查询指定股票所属的所有板块(行业、概念、风格等)。
参数:
market -- 市场代码(Market.SH / Market.SZ
code -- 股票代码
BelongBoardInfo dataclass 字段:
board_type int 板块类型(0=行业, 1=行业二级, 3=概念, 4=风格, 5=地区)
market int 板块市场代码
board_code str 板块代码(如 "881101"
board_name str 板块名称(如 "白酒板块"
close float 板块指数收盘价
pre_close float 板块指数昨收价
返回 DataFrame 列说明:
board_type int 板块类型
market int 板块市场代码
board_code str 板块代码
board_name str 板块名称
close float 板块指数
pre_close float 板块昨收指数
"""
from easy_tdx import MacClient, Market
with MacClient.from_best_host() as c:
# 查询贵州茅台所属板块
df = c.get_belong_board(Market.SH, "600519")
print(df.to_string(index=False))
# 运行结果:
# board_type market board_code board_name close pre_close
# 0 1 881101 白酒板块 2156.80 2140.50
# 0 1 881102 食品饮料 1580.30 1568.90
# 3 1 885201 奢侈品 1256.40 1248.70
# 3 1 885202 品牌龙头 1890.50 1879.30
# 3 1 885203 消费升级 1356.80 1349.20
# 3 1 885204 MSCI概念 1680.20 1671.50
# 3 1 885205 沪股通标的 1780.90 1770.60
# 3 1 885206 茅台概念 2580.00 2565.30