mirror of
https://ghfast.top/https://github.com/aeroxw/easy-tdx.git
synced 2026-09-12 14:34:15 +08:00
- 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>
24 lines
627 B
Python
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))
|