Files
easy-tdx/examples/06_finance/price_limits.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

24 lines
627 B
Python

"""演示:计算个股涨跌停价格。"""
import pandas as pd
from xmtdx import TdxClient, Market
CODE = "600519"
NAME = "贵州茅台"
with TdxClient.from_best_host() as c:
quotes = c.get_security_quotes([(Market.SH, CODE)])
if quotes:
q = quotes[0]
limit_up, limit_down = c.get_price_limits(
Market.SH, CODE, NAME, q.pre_close
)
df = pd.DataFrame([{
"代码": CODE,
"名称": NAME,
"昨收": q.pre_close,
"涨停价": limit_up,
"跌停价": limit_down,
}])
print(df.to_string(index=False))