Files
easy_tdx_max/examples/06_finance/xdxr_info.py
T
GitHubandClaude Opus 4.7 7fd6e610cf feat: add examples (01-08), fix index bars parsing, add ruff hook
- Add example scripts for all API categories (connection, market info,
  kline, minute, transaction, finance, block, fund flow)
- Fix GetIndexBarsCmd: index bar records have 4 extra bytes (advance/
  decline counts) that were not consumed, causing pos drift and
  corrupted dates/volumes for all records after the first
- Fix price_limits.py example (SecurityQuote has no name attr)
- Fix finance_info.py display (scientific notation -> formatted numbers)
- Add PostToolUse ruff hook (scripts/ruff_hook.py)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-21 18:36:50 +08:00

18 lines
665 B
Python

"""演示:获取除权除息历史记录。"""
import pandas as pd
from xmtdx import TdxClient, Market, XDXR_CATEGORY_NAMES
with TdxClient.from_best_host() as c:
records = c.get_xdxr_info(Market.SH, "600519")
df = pd.DataFrame([{
"日期": f"{r.year}-{r.month:02d}-{r.day:02d}",
"类型": XDXR_CATEGORY_NAMES.get(r.category, f"未知({r.category})"),
"每股分红(元)": r.fenhong,
"送转股比例": r.songzhuangu,
"配股价": r.peigujia,
"配股比例": r.peigu,
} for r in records])
print(f"贵州茅台 除权除息记录,共 {len(df)} 条:")
print(df.tail(10).to_string(index=False))