mirror of
https://ghfast.top/https://github.com/aeroxw/easy-tdx.git
synced 2026-09-12 15:44:15 +08:00
1. 行情增强:解析 SecurityQuote 中的 limit_up (涨停价) 和 limit_down (跌停价)。 2. 新增命令:实现 GetReportFileCmd (0x06B9),支持从服务器拉取 base_info.zip 等大文件。 3. 客户端 API:TdxClient/AsyncTdxClient 增加 get_report_file 方法,支持自动分片。 4. 验证脚本:增加 verify_limits.py 和 verify_report_file.py 实测脚本。 5. 文档更新:README.md 同步 API 变更及数据模型更新。
28 lines
1.1 KiB
Python
28 lines
1.1 KiB
Python
"""验证涨跌停价。"""
|
|
import sys
|
|
import pathlib
|
|
|
|
# 添加 src 到 path
|
|
sys.path.insert(0, str(pathlib.Path(__file__).parent.parent / "src"))
|
|
|
|
from xmtdx import TdxClient, Market
|
|
|
|
def main():
|
|
print("正在连接服务器验证涨跌停...")
|
|
with TdxClient.from_best_host() as c:
|
|
# 选取一些知名 A 股
|
|
stocks = [(Market.SH, "600000"), (Market.SZ, "000001"), (Market.SZ, "300750")]
|
|
quotes = c.get_security_quotes(stocks)
|
|
|
|
print(f" {'代码':>8} {'昨收':>8} {'现价':>8} {'涨停价':>8} {'跌停价':>8} {'涨速':>8}")
|
|
for q in quotes:
|
|
print(f" {q.code:>8} {q.pre_close:>8.2f} {q.price:>8.2f} {q.limit_up:>8.2f} {q.limit_down:>8.2f} {q.rise_speed:>8.2f}")
|
|
|
|
# 校验涨停价是否大约为昨收 * 1.1 (主板/深证) 或 * 1.2 (创业板)
|
|
expected_up = round(q.pre_close * (1.2 if q.code.startswith("300") else 1.1), 2)
|
|
if abs(q.limit_up - expected_up) > 0.02:
|
|
print(f" [!] 涨停价异常:预期约 {expected_up}")
|
|
|
|
if __name__ == "__main__":
|
|
main()
|