通达信数据 - 使用通达信量化TQ(tdx quant)(2) - 工作原理

Published

通达信数据 - 使用通达信量化TQ(tdx quant)(2) - 工作原理

 

Tqcenter.py

通过ctypes库加载TPythClient.dll;封装与DLL交互的核心逻辑;发起请求(如获取行情数据)并解析TPythClient.dll返回的结果;

D:\Thirdprogram\newtdxtqv772\PYPlugins\user\tqcenter.py

'''
    Version: 1.0.4
    2026-03-06
'''

global_dll_path = Path(__file__).resolve().parents[1] / 'TPythClient.dll'
dll = ctypes.CDLL(str(global_dll_path))

# 设置DLL函数的返回类型
dll.InitConnect.restype = ctypes.c_char_p       # 初始化 获取id
dll.GetStockListInStr.restype = ctypes.c_char_p  # 获取股票列表
dll.GetHISDATsInStr.restype = ctypes.c_char_p   # K线数据

 

 

TPythClient.dll

进程间通信:通过tdxw.exe共享内存/消息队列:实现DLL与tdxw.exe的高效数据交换。

D:\Thirdprogram\newtdxtqv772\PYPlugins\TPythClient.dll

 

tdxw.exe - 通达信客户端

 

tdxw.exe运行后,接口已经暴漏给外部

提供股票行情、交易接口等核心功能;

接收DLL的数据请求指令(如查询某股票价格)。

推送数据到DLL的缓冲区(如分时成交数据)

 

 

useful links

https://mp.weixin.qq.com/s?__biz=MzUxMTU0ODMxMg==&mid=2247484960&idx=1&sn=7cccc70996ddbe622a028d9b87222ed4&chksm=f97348d7ce04c1c1ef4393c213555d0ed72bf5b7f4ad000374c2b834e24c9367be6f8d8d5295&cur_album_id=4304656852933361666&scene=189#wechat_redirect