mirror of
https://ghfast.top/https://github.com/aeroxw/easy_tdx_max.git
synced 2026-09-12 14:34:18 +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>
14 lines
475 B
Python
14 lines
475 B
Python
"""演示:自动从候选服务器中选延迟最低的建立连接。"""
|
|
|
|
from xmtdx import TdxClient, Market
|
|
|
|
# 方式一:手动指定服务器
|
|
with TdxClient("180.153.18.170") as c:
|
|
print(f"已连接到 {c._host}:{c._port}")
|
|
|
|
# 方式二:自动优选最低延迟服务器
|
|
with TdxClient.from_best_host() as c:
|
|
print(f"已自动选择最优服务器: {c._host}:{c._port}")
|
|
count = c.get_security_count(Market.SH)
|
|
print(f"沪市证券总数: {count}")
|