Files
easy-tdx/examples/02_market_info/security_quotes.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

26 lines
798 B
Python

"""演示:批量获取实时五档行情。最多支持 80 只/次。"""
import pandas as pd
from xmtdx import TdxClient, Market
with TdxClient.from_best_host() as c:
stocks = [
(Market.SH, "600000"), # 浦发银行
(Market.SH, "600519"), # 贵州茅台
(Market.SZ, "000001"), # 平安银行
(Market.SZ, "000858"), # 五粮液
]
quotes = c.get_security_quotes(stocks)
df = pd.DataFrame([{
"代码": q.code,
"现价": q.price,
"涨跌幅%": (q.price - q.pre_close) / q.pre_close * 100,
"今开": q.open,
"最高": q.high,
"最低": q.low,
"昨收": q.pre_close,
"成交量(手)": q.vol,
"成交额": q.amount,
} for q in quotes])
print(df.to_string(index=False))