mirror of
https://ghfast.top/https://github.com/aeroxw/easy_tdx_max.git
synced 2026-09-12 16:54:20 +08:00
抓包+对值锚定确认:0x1231 响应中 price 与 pre_close 之间的 float 是 "当前排序列的值"(板块与领涨股各一份),并非固定涨速;此前硬编码 sort_column=0(涨跌幅,仅排序键、值槽恒 0),故该列永远全 0。 排序列映射(实测):0=涨跌幅(值槽恒0) 1=涨速 2=3日 3=20日 4=60日 5=年初至今 6=5日 7=10日。 - 新增 BoardSortColumn 枚举并公开导出;get_board_list(sync/async) 新增 sort_column 参数,取涨速传 SPEED,默认涨跌幅排序行为不变 - BoardInfo 字段更名 rise_speed→sort_value、symbol_rise_speed→ symbol_sort_value(旧名语义错误且恒 0,属破坏性更名) - Web /board-mac/list 新增 sort_column 参数;CLI board-list 新增 --sort - 新增 9 个测试;README 示例更新
128 lines
2.8 KiB
Python
128 lines
2.8 KiB
Python
"""easy_tdx — 通达信 TCP 协议 A 股行情数据客户端。
|
|
|
|
快速开始::
|
|
|
|
from easy_tdx import TdxClient, Market, KlineCategory
|
|
|
|
with TdxClient("180.153.18.170") as c:
|
|
count = c.get_security_count(Market.SH)
|
|
bars = c.get_security_bars(Market.SH, "600000", KlineCategory.DAY, 0, 5)
|
|
|
|
asyncio 版本::
|
|
|
|
import asyncio
|
|
from easy_tdx import AsyncTdxClient, Market, KlineCategory
|
|
|
|
async def main():
|
|
async with AsyncTdxClient("180.153.18.170") as c:
|
|
bars = await c.get_security_bars(Market.SH, "600000", KlineCategory.DAY, 0, 5)
|
|
|
|
asyncio.run(main())
|
|
"""
|
|
|
|
from .client import AsyncTdxClient, TdxClient
|
|
from .config import save_best_ex_host, save_best_host
|
|
from .ex.client import AsyncExTdxClient, ExTdxClient
|
|
from .ex.mac_client import AsyncMacExClient, MacExClient
|
|
from .ex.models import KNOWN_EX_HOSTS
|
|
from .exceptions import TdxCommandError, TdxConnectionError, TdxDecodeError, TdxError
|
|
from .mac.client import AsyncMacClient, MacClient
|
|
from .mac.enums import (
|
|
Adjust,
|
|
BoardSortColumn,
|
|
BoardType,
|
|
Category,
|
|
ExMarket,
|
|
FilterType,
|
|
Period,
|
|
SortOrder,
|
|
SortType,
|
|
)
|
|
from .models import (
|
|
XDXR_CATEGORY_NAMES,
|
|
CompanyInfoCategory,
|
|
FinanceInfo,
|
|
FinancialFileInfo,
|
|
FinancialRecord,
|
|
FundFlow,
|
|
HistoricalFundFlow,
|
|
KlineCategory,
|
|
Market,
|
|
MarketStat,
|
|
MinuteBar,
|
|
SecurityBar,
|
|
SecurityInfo,
|
|
SecurityQuote,
|
|
TdxBlock,
|
|
TransactionRecord,
|
|
XdxrRecord,
|
|
)
|
|
from .transport.sync import CALC_HOSTS, KNOWN_HOSTS, MAC_HOSTS, ping_all, ping_mac_all
|
|
from .unified import AsyncUnifiedTdxClient, UnifiedTdxClient
|
|
|
|
__all__ = [
|
|
# 客户端
|
|
"TdxClient",
|
|
"AsyncTdxClient",
|
|
"MacClient",
|
|
"AsyncMacClient",
|
|
"MacExClient",
|
|
"AsyncMacExClient",
|
|
"UnifiedTdxClient",
|
|
"AsyncUnifiedTdxClient",
|
|
# 枚举
|
|
"Market",
|
|
"KlineCategory",
|
|
"Adjust",
|
|
"BoardSortColumn",
|
|
"BoardType",
|
|
"Category",
|
|
"ExMarket",
|
|
"FilterType",
|
|
"Period",
|
|
"SortOrder",
|
|
"SortType",
|
|
# 数据模型
|
|
"SecurityBar",
|
|
"SecurityQuote",
|
|
"SecurityInfo",
|
|
"MinuteBar",
|
|
"TransactionRecord",
|
|
"XdxrRecord",
|
|
"XDXR_CATEGORY_NAMES",
|
|
"FinanceInfo",
|
|
"CompanyInfoCategory",
|
|
"FinancialFileInfo",
|
|
"FinancialRecord",
|
|
"TdxBlock",
|
|
"MarketStat",
|
|
"FundFlow",
|
|
"HistoricalFundFlow",
|
|
# 异常
|
|
"TdxError",
|
|
"TdxConnectionError",
|
|
"TdxDecodeError",
|
|
"TdxCommandError",
|
|
# 扩展行情
|
|
"ExTdxClient",
|
|
"AsyncExTdxClient",
|
|
"KNOWN_EX_HOSTS",
|
|
# 工具
|
|
"ping_all",
|
|
"ping_mac_all",
|
|
"KNOWN_HOSTS",
|
|
"CALC_HOSTS",
|
|
"MAC_HOSTS",
|
|
"save_best_host",
|
|
"save_best_ex_host",
|
|
]
|
|
|
|
|
|
def _get_version() -> str:
|
|
from importlib.metadata import version
|
|
|
|
return version("easy-tdx")
|
|
|
|
|
|
__version__ = _get_version()
|