通达信行情数据自研接口,不依赖客户端
Project description
TDXAPI - 通达信行情数据自研接口
不依赖通达信客户端,直接通过 TCP 协议连接行情服务器获取数据。
协议已与 pytdx 源码逐命令校准,二进制完全一致。
快速开始
pip install -e .
from tdxapi import TdxClient
with TdxClient() as client:
# 实时行情
q = client.get_quote("600519", "SH")
print(f"贵州茅台: {q.price}元")
# K线
bars = client.get_bars("600519", "SH", period="1d", count=100)
print(f"收盘价: {[b.close for b in bars]}")
# 分钟K线
bars = client.get_bars("600519", "SH", period="1min", count=240)
支持的数据类型
| 类型 | 方法 | 状态 |
|---|---|---|
| 实时行情(5档) | get_quote() |
✅ |
| K线(日/周/月/年) | get_bars(period="1d") |
✅ |
| 分钟K线(1/5/15/30/60分) | get_bars(period="1min/5m/15m") |
✅ |
| 分时数据 | get_minute_time() |
✅ |
| 分笔成交 | get_transactions() |
✅ |
| 股票列表 | get_security_list() |
✅ |
| 除权除息 | get_xdxr_info() |
✅ |
| 财务数据 | get_finance_info() |
✅ |
| 指数/期货行情 | get_index_quote() |
✅ |
高级功能
# 多线程安全(默认开启)
client = TdxClient(thread_safe=True)
# 心跳保活(默认开启)
client = TdxClient(heartbeat=True)
# 指数行情
client.get_index_quote("000001")
# 期货行情
client.get_futures_quote("IF2504", market=6)
K线周期
| period | 说明 |
|---|---|
1d |
日线 |
1w |
周线 |
1m |
月线 |
1min |
1分钟 |
5m |
5分钟 |
15m |
15分钟 |
30m |
30分钟 |
60m |
60分钟 |
验证结果
- 单元测试: 69/69 通过
- 协议包: 18/18 与 pytdx 源码一致
- 数据验证: 与东方财富、新浪等公开数据对比一致
600519 贵州茅台验证
| 数据 | TdxAPI | 参考值 |
|---|---|---|
| 当前价 | 1460.00 | ~1460 |
| 2026-04-03 收盘 | 1460.00 | 1460.00 |
| 1分钟K线 | 正常 | 正常 |
| 5分钟K线 | 正常 | 正常 |
项目结构
tdxapi/
├── src/tdxapi/
│ ├── protocol/ # 协议层(包头、请求构造)
│ ├── parser/ # 解析器(二进制→结构化数据)
│ ├── network/ # 网络层(连接、重连、测速)
│ ├── models/ # 数据模型
│ └── utils/ # 工具函数
├── tests/ # 单元测试 (69个,100%通过)
└── examples/ # 使用示例
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ten2net_tdxapi-0.1.0.tar.gz
(23.0 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ten2net_tdxapi-0.1.0.tar.gz.
File metadata
- Download URL: ten2net_tdxapi-0.1.0.tar.gz
- Upload date:
- Size: 23.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9afb1395686e1ae881e00cd9702555a6c39d6654c577e6554150f90783c008ae
|
|
| MD5 |
fe420a6189e9b3f43f42c98b7da6e85e
|
|
| BLAKE2b-256 |
64a745ad497304b657d5c5319d84c1141e6587784e8d9ca144d71e814e8523be
|
File details
Details for the file ten2net_tdxapi-0.1.0-py3-none-any.whl.
File metadata
- Download URL: ten2net_tdxapi-0.1.0-py3-none-any.whl
- Upload date:
- Size: 18.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
11a5279e573f2a5e1c839a872a19d5add9ea01ede2d3828276b929f954e8fe3c
|
|
| MD5 |
04e9385826d4c5b8d3b763afed669613
|
|
| BLAKE2b-256 |
64c4a192fc8016fa9878f8bb991587318b4fa1441319848189e2c0c52e81e01e
|