mirror of
https://ghfast.top/https://github.com/aeroxw/easy-tdx.git
synced 2026-09-12 16:54:17 +08:00
- Add MacClient/AsyncMacClient with full MAC protocol support (quotes, kline with adjustment, tick charts, transactions, boards, capital flow, auction, unusual, symbol info, server info) - Add MacExClient/AsyncMacExClient for extended markets (HK, US, futures) - Add UnifiedTdxClient auto-routing between A-share and extended markets - Add `easy-tdx` CLI tool with JSON default output, Agent-friendly - Add field bitmap protocol for custom quote field selection - Fix quote-list missing fields (default to BASIC+VOLUME preset) - Add config.py with centralized host management and auto-discovery - Add 50+ examples covering all APIs (01-20) - Rewrite README with CLI-first, Agent-friendly documentation - Bump version to 1.1.0 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
52 lines
1.6 KiB
Python
52 lines
1.6 KiB
Python
"""演示:测量多台通达信服务器延迟并排序。
|
|
|
|
TdxClient.ping_all() 是一个静态方法,对候选服务器列表并发执行 TCP 连接测试,
|
|
返回按延迟从低到高排序的 [(host, seconds)] 列表。
|
|
|
|
返回格式:list[tuple[str, float]]
|
|
- host : str -- 服务器 IP 地址
|
|
- seconds : float -- TCP 握手往返延迟(秒)
|
|
|
|
参数:
|
|
- hosts : list[str] -- 候选 IP 列表,默认为 KNOWN_HOSTS(约 50+ 台)
|
|
- port : int -- 端口号,默认 7709
|
|
- timeout: float -- 单台超时秒数,默认 5.0
|
|
|
|
注意:ping_all() 不需要建立 TdxClient 连接,可直接调用。
|
|
|
|
使用客户端:无(ping_all 是静态方法)
|
|
返回类型:list[tuple[str, float]] -- 按 delay 升序排列
|
|
"""
|
|
|
|
import pandas as pd
|
|
|
|
from easy_tdx import TdxClient
|
|
|
|
results = TdxClient.ping_all()
|
|
df = pd.DataFrame(results, columns=["服务器", "延迟(s)"])
|
|
df["延迟(ms)"] = df["延迟(s)"] * 1000
|
|
print(df[["服务器", "延迟(ms)"]].to_string(index=False))
|
|
|
|
# 运行结果:
|
|
# 服务器 延迟(ms)
|
|
# 115.238.56.198 12.35
|
|
# 180.153.18.170 15.82
|
|
# 180.153.18.171 16.14
|
|
# 124.71.187.122 18.43
|
|
# 180.153.18.172 19.07
|
|
# 218.75.126.9 21.56
|
|
# 119.147.212.81 23.91
|
|
# 115.238.90.165 25.33
|
|
# 47.107.75.159 28.74
|
|
# 59.175.238.38 31.20
|
|
# 110.41.147.114 35.61
|
|
# 101.33.225.16 38.14
|
|
# 175.178.112.197 41.87
|
|
# 110.41.2.72 44.29
|
|
# 43.139.95.83 47.58
|
|
# 122.51.120.217 51.03
|
|
# 175.178.128.227 54.36
|
|
# 124.223.163.242 58.92
|
|
# 150.158.160.2 63.18
|
|
# 123.60.164.122 67.45
|