tdxaidata 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- tdxaidata-1.0.0/LICENSE +21 -0
- tdxaidata-1.0.0/MANIFEST.in +4 -0
- tdxaidata-1.0.0/PKG-INFO +121 -0
- tdxaidata-1.0.0/README.md +90 -0
- tdxaidata-1.0.0/pyproject.toml +43 -0
- tdxaidata-1.0.0/setup.cfg +4 -0
- tdxaidata-1.0.0/src/tdxaidata/__init__.py +18 -0
- tdxaidata-1.0.0/src/tdxaidata/docs/tqServer/344/275/277/347/224/250/346/226/207/346/241/243.md +2228 -0
- tdxaidata-1.0.0/src/tdxaidata/lib/TdxAiData.dll +0 -0
- tdxaidata-1.0.0/src/tdxaidata/lib/TdxAiData.ini +16 -0
- tdxaidata-1.0.0/src/tdxaidata/lib/__init__.py +1 -0
- tdxaidata-1.0.0/src/tdxaidata/lib/libTdxAiData.dylib +0 -0
- tdxaidata-1.0.0/src/tdxaidata/lib/libTdxAiData.so +0 -0
- tdxaidata-1.0.0/src/tdxaidata/lib/mfc100.dll +0 -0
- tdxaidata-1.0.0/src/tdxaidata/lib/msvcp100.dll +0 -0
- tdxaidata-1.0.0/src/tdxaidata/lib/msvcr100.dll +0 -0
- tdxaidata-1.0.0/src/tdxaidata/tqserver.py +969 -0
- tdxaidata-1.0.0/src/tdxaidata.egg-info/PKG-INFO +121 -0
- tdxaidata-1.0.0/src/tdxaidata.egg-info/SOURCES.txt +20 -0
- tdxaidata-1.0.0/src/tdxaidata.egg-info/dependency_links.txt +1 -0
- tdxaidata-1.0.0/src/tdxaidata.egg-info/requires.txt +7 -0
- tdxaidata-1.0.0/src/tdxaidata.egg-info/top_level.txt +1 -0
tdxaidata-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 meiziyao
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
tdxaidata-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tdxaidata
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: 通达信 TdxAiData 行情/专业数据 Python 接口(跨平台 Windows/macOS/Linux)
|
|
5
|
+
Author: tdx-meiziyao
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://www.tdx.com.cn
|
|
8
|
+
Keywords: tdx,通达信,quant,quantitative,行情,A股,股票
|
|
9
|
+
Classifier: Development Status :: 4 - Beta
|
|
10
|
+
Classifier: Intended Audience :: Financial and Insurance Industry
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
19
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
20
|
+
Classifier: Operating System :: MacOS
|
|
21
|
+
Classifier: Topic :: Office/Business :: Financial :: Investment
|
|
22
|
+
Requires-Python: >=3.8
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
Provides-Extra: pandas
|
|
26
|
+
Requires-Dist: pandas>=1.0; extra == "pandas"
|
|
27
|
+
Provides-Extra: dev
|
|
28
|
+
Requires-Dist: build>=1.0; extra == "dev"
|
|
29
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
30
|
+
Dynamic: license-file
|
|
31
|
+
|
|
32
|
+
# tdxaidata
|
|
33
|
+
|
|
34
|
+
通达信 TdxAiData 行情 / 专业数据 Python 数据接口(**跨平台:Windows / macOS / Linux**)。
|
|
35
|
+
|
|
36
|
+
基于 TdxAiData 原生动态库,用 `ctypes` 直接调用,对齐 `tqcenter` 命名,提供行情、证券基础信息、板块、交易日、专业数据、除权除息、股本、涨跌停、分笔、分时与实时订阅能力。**不依赖** `tqcenter.py`、`TPyth.dll`、策略运行环境或通达信客户端交互。
|
|
37
|
+
|
|
38
|
+
## 特性
|
|
39
|
+
|
|
40
|
+
- 跨平台:Windows(`TdxAiData.dll`)/ macOS(`libTdxAiData.dylib`)/ Linux(`libTdxAiData.so`),随包自动匹配
|
|
41
|
+
- 与 tqcenter 一致的接口命名:`get_market_data`、`get_market_snapshot`、`get_financial_data`、`subscribe` 等
|
|
42
|
+
- K 线与除权除息在装有 pandas 时返回 `DataFrame`
|
|
43
|
+
- 可选 `TDX_AI_DATA_LIB` 环境变量指定动态库路径
|
|
44
|
+
|
|
45
|
+
## 安装
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
pip install tdxaidata
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
可选:pandas 支持
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
pip install tdxaidata[pandas]
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## 快速开始
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
from tdxaidata import tqs
|
|
61
|
+
|
|
62
|
+
# 实时行情快照
|
|
63
|
+
snap = tqs.get_market_snapshot("600000.SH", ["Name", "Price", "Close"])
|
|
64
|
+
print(snap)
|
|
65
|
+
|
|
66
|
+
# K 线(需 pandas)
|
|
67
|
+
market = tqs.get_market_data(
|
|
68
|
+
field_list=["Close", "Volume"],
|
|
69
|
+
stock_list=["600000.SH", "000001.SZ"],
|
|
70
|
+
period="1d",
|
|
71
|
+
count=100,
|
|
72
|
+
dividend_type="front",
|
|
73
|
+
)
|
|
74
|
+
print(market["Close"].tail())
|
|
75
|
+
|
|
76
|
+
# 订阅实时行情(保持进程运行)
|
|
77
|
+
import time
|
|
78
|
+
|
|
79
|
+
def on_quote(data):
|
|
80
|
+
print("[行情]", data)
|
|
81
|
+
|
|
82
|
+
tqs.subscribe(stock_list=["000001.SZ", "600000.SH"], callback=on_quote)
|
|
83
|
+
time.sleep(30)
|
|
84
|
+
tqs.unsubscribe()
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## 配置(必读)
|
|
88
|
+
|
|
89
|
+
随包提供 `TdxAiData.ini`(位于包内 `tdxaidata/lib/`),默认指向通达信官方 AI 数据服务(行情 `aihs.tdx.com.cn:7709`、数据 `aids.tdx.com.cn:7727`)。**Token 未预填**,安装后必须按实际环境修改:
|
|
90
|
+
|
|
91
|
+
- `[TcHqHost]` / `[TcDsHost]`:行情 / 数据服务地址(默认已指向官方域名,一般无需改动)
|
|
92
|
+
- `[Token]`:填写 `token=`(**必填**,登录通达信个人版商城 → 会员中心 → 积分和Key管理 → 创建数据服务 Key;缺失或错误会导致连接 / 认证失败)
|
|
93
|
+
|
|
94
|
+
> 动态库初始化时读取其所在目录(`tdxaidata/lib/`)的 `TdxAiData.ini`。也可以不改模板,通过环境变量 `TDX_AI_DATA_LIB` 指向外部动态库目录。
|
|
95
|
+
|
|
96
|
+
## 动态库查找顺序
|
|
97
|
+
|
|
98
|
+
1. 构造 `_NativeTdxAiData(dll_path)` 显式传入的路径
|
|
99
|
+
2. 环境变量 `TDX_AI_DATA_LIB`
|
|
100
|
+
3. 包内 `tdxaidata/lib/` 下的平台对应动态库(`TdxAiData.dll` / `libTdxAiData.dylib` / `libTdxAiData.so`)
|
|
101
|
+
4. 模块同目录(源码部署兼容)
|
|
102
|
+
|
|
103
|
+
## 接口概览
|
|
104
|
+
|
|
105
|
+
- 行情与基础信息:`get_market_data` / `get_divid_factors` / `get_stock_info` / `get_market_snapshot` / `get_more_info`
|
|
106
|
+
- 证券列表、板块与交易日:`get_stock_list` / `get_sector_list` / `get_stock_list_in_sector` / `get_trading_dates` / `get_zzgz_stocklist`
|
|
107
|
+
- 专业数据:`get_financial_data` / `get_financial_data_by_date` / `get_gpjy_value(_by_date)` / `get_bkjy_value(_by_date)` / `get_scjy_value(_by_date)` / `get_gp_one_data`
|
|
108
|
+
- 关系 / 可转债 / ETF / 涨跌停 / 股本:`get_relation` / `get_kzz_info` / `get_trackzs_etf_info` / `get_zdt_data` / `get_gb_info(_by_date)` / `get_exday_data`
|
|
109
|
+
- 分笔 / 分时:`get_tick_data` / `get_minute_data`
|
|
110
|
+
- 订阅:`subscribe` / `unsubscribe` / `get_subscribe_hq_stock_list`
|
|
111
|
+
- 文件下载:`download_file`(HTTP,不依赖动态库)
|
|
112
|
+
|
|
113
|
+
> 完整参数说明与字段参考见包内 `tdxaidata/docs/tqServer使用文档.md`(随 wheel/sdist 分发;源码仓库另附 `SKILL.md`)。
|
|
114
|
+
|
|
115
|
+
## 错误处理
|
|
116
|
+
|
|
117
|
+
新版多数错误(库未加载、返回空 / 无效 JSON、`ErrorId != 0`、参数非法等)会**打印 `[错误]` 提示并返回空值**(`None` / `{}` / `[]`),调用后请检查返回值。
|
|
118
|
+
|
|
119
|
+
## 许可
|
|
120
|
+
|
|
121
|
+
MIT License
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# tdxaidata
|
|
2
|
+
|
|
3
|
+
通达信 TdxAiData 行情 / 专业数据 Python 数据接口(**跨平台:Windows / macOS / Linux**)。
|
|
4
|
+
|
|
5
|
+
基于 TdxAiData 原生动态库,用 `ctypes` 直接调用,对齐 `tqcenter` 命名,提供行情、证券基础信息、板块、交易日、专业数据、除权除息、股本、涨跌停、分笔、分时与实时订阅能力。**不依赖** `tqcenter.py`、`TPyth.dll`、策略运行环境或通达信客户端交互。
|
|
6
|
+
|
|
7
|
+
## 特性
|
|
8
|
+
|
|
9
|
+
- 跨平台:Windows(`TdxAiData.dll`)/ macOS(`libTdxAiData.dylib`)/ Linux(`libTdxAiData.so`),随包自动匹配
|
|
10
|
+
- 与 tqcenter 一致的接口命名:`get_market_data`、`get_market_snapshot`、`get_financial_data`、`subscribe` 等
|
|
11
|
+
- K 线与除权除息在装有 pandas 时返回 `DataFrame`
|
|
12
|
+
- 可选 `TDX_AI_DATA_LIB` 环境变量指定动态库路径
|
|
13
|
+
|
|
14
|
+
## 安装
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pip install tdxaidata
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
可选:pandas 支持
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
pip install tdxaidata[pandas]
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## 快速开始
|
|
27
|
+
|
|
28
|
+
```python
|
|
29
|
+
from tdxaidata import tqs
|
|
30
|
+
|
|
31
|
+
# 实时行情快照
|
|
32
|
+
snap = tqs.get_market_snapshot("600000.SH", ["Name", "Price", "Close"])
|
|
33
|
+
print(snap)
|
|
34
|
+
|
|
35
|
+
# K 线(需 pandas)
|
|
36
|
+
market = tqs.get_market_data(
|
|
37
|
+
field_list=["Close", "Volume"],
|
|
38
|
+
stock_list=["600000.SH", "000001.SZ"],
|
|
39
|
+
period="1d",
|
|
40
|
+
count=100,
|
|
41
|
+
dividend_type="front",
|
|
42
|
+
)
|
|
43
|
+
print(market["Close"].tail())
|
|
44
|
+
|
|
45
|
+
# 订阅实时行情(保持进程运行)
|
|
46
|
+
import time
|
|
47
|
+
|
|
48
|
+
def on_quote(data):
|
|
49
|
+
print("[行情]", data)
|
|
50
|
+
|
|
51
|
+
tqs.subscribe(stock_list=["000001.SZ", "600000.SH"], callback=on_quote)
|
|
52
|
+
time.sleep(30)
|
|
53
|
+
tqs.unsubscribe()
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## 配置(必读)
|
|
57
|
+
|
|
58
|
+
随包提供 `TdxAiData.ini`(位于包内 `tdxaidata/lib/`),默认指向通达信官方 AI 数据服务(行情 `aihs.tdx.com.cn:7709`、数据 `aids.tdx.com.cn:7727`)。**Token 未预填**,安装后必须按实际环境修改:
|
|
59
|
+
|
|
60
|
+
- `[TcHqHost]` / `[TcDsHost]`:行情 / 数据服务地址(默认已指向官方域名,一般无需改动)
|
|
61
|
+
- `[Token]`:填写 `token=`(**必填**,登录通达信个人版商城 → 会员中心 → 积分和Key管理 → 创建数据服务 Key;缺失或错误会导致连接 / 认证失败)
|
|
62
|
+
|
|
63
|
+
> 动态库初始化时读取其所在目录(`tdxaidata/lib/`)的 `TdxAiData.ini`。也可以不改模板,通过环境变量 `TDX_AI_DATA_LIB` 指向外部动态库目录。
|
|
64
|
+
|
|
65
|
+
## 动态库查找顺序
|
|
66
|
+
|
|
67
|
+
1. 构造 `_NativeTdxAiData(dll_path)` 显式传入的路径
|
|
68
|
+
2. 环境变量 `TDX_AI_DATA_LIB`
|
|
69
|
+
3. 包内 `tdxaidata/lib/` 下的平台对应动态库(`TdxAiData.dll` / `libTdxAiData.dylib` / `libTdxAiData.so`)
|
|
70
|
+
4. 模块同目录(源码部署兼容)
|
|
71
|
+
|
|
72
|
+
## 接口概览
|
|
73
|
+
|
|
74
|
+
- 行情与基础信息:`get_market_data` / `get_divid_factors` / `get_stock_info` / `get_market_snapshot` / `get_more_info`
|
|
75
|
+
- 证券列表、板块与交易日:`get_stock_list` / `get_sector_list` / `get_stock_list_in_sector` / `get_trading_dates` / `get_zzgz_stocklist`
|
|
76
|
+
- 专业数据:`get_financial_data` / `get_financial_data_by_date` / `get_gpjy_value(_by_date)` / `get_bkjy_value(_by_date)` / `get_scjy_value(_by_date)` / `get_gp_one_data`
|
|
77
|
+
- 关系 / 可转债 / ETF / 涨跌停 / 股本:`get_relation` / `get_kzz_info` / `get_trackzs_etf_info` / `get_zdt_data` / `get_gb_info(_by_date)` / `get_exday_data`
|
|
78
|
+
- 分笔 / 分时:`get_tick_data` / `get_minute_data`
|
|
79
|
+
- 订阅:`subscribe` / `unsubscribe` / `get_subscribe_hq_stock_list`
|
|
80
|
+
- 文件下载:`download_file`(HTTP,不依赖动态库)
|
|
81
|
+
|
|
82
|
+
> 完整参数说明与字段参考见包内 `tdxaidata/docs/tqServer使用文档.md`(随 wheel/sdist 分发;源码仓库另附 `SKILL.md`)。
|
|
83
|
+
|
|
84
|
+
## 错误处理
|
|
85
|
+
|
|
86
|
+
新版多数错误(库未加载、返回空 / 无效 JSON、`ErrorId != 0`、参数非法等)会**打印 `[错误]` 提示并返回空值**(`None` / `{}` / `[]`),调用后请检查返回值。
|
|
87
|
+
|
|
88
|
+
## 许可
|
|
89
|
+
|
|
90
|
+
MIT License
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "tdxaidata"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "通达信 TdxAiData 行情/专业数据 Python 接口(跨平台 Windows/macOS/Linux)"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.8"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
authors = [{ name = "tdx-meiziyao" }]
|
|
13
|
+
keywords = ["tdx", "通达信", "quant", "quantitative", "行情", "A股", "股票"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 4 - Beta",
|
|
16
|
+
"Intended Audience :: Financial and Insurance Industry",
|
|
17
|
+
"Programming Language :: Python :: 3",
|
|
18
|
+
"Programming Language :: Python :: 3.8",
|
|
19
|
+
"Programming Language :: Python :: 3.9",
|
|
20
|
+
"Programming Language :: Python :: 3.10",
|
|
21
|
+
"Programming Language :: Python :: 3.11",
|
|
22
|
+
"Programming Language :: Python :: 3.12",
|
|
23
|
+
"Programming Language :: Python :: 3.13",
|
|
24
|
+
"Operating System :: Microsoft :: Windows",
|
|
25
|
+
"Operating System :: POSIX :: Linux",
|
|
26
|
+
"Operating System :: MacOS",
|
|
27
|
+
"Topic :: Office/Business :: Financial :: Investment",
|
|
28
|
+
]
|
|
29
|
+
dependencies = []
|
|
30
|
+
|
|
31
|
+
[project.optional-dependencies]
|
|
32
|
+
pandas = ["pandas>=1.0"]
|
|
33
|
+
dev = ["build>=1.0", "pytest>=7.0"]
|
|
34
|
+
|
|
35
|
+
[project.urls]
|
|
36
|
+
Homepage = "https://www.tdx.com.cn"
|
|
37
|
+
|
|
38
|
+
[tool.setuptools]
|
|
39
|
+
package-dir = { "" = "src" }
|
|
40
|
+
packages = ["tdxaidata", "tdxaidata.lib"]
|
|
41
|
+
|
|
42
|
+
[tool.setuptools.package-data]
|
|
43
|
+
tdxaidata = ["py.typed", "docs/*.md", "lib/*.dll", "lib/*.so", "lib/*.dylib", "lib/*.ini"]
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"""tdxaidata —— 通达信 TdxAiData Python 数据接口(跨平台)。
|
|
2
|
+
|
|
3
|
+
基于 TdxAiData 原生动态库(Windows: ``TdxAiData.dll``、macOS: ``libTdxAiData.dylib``、
|
|
4
|
+
Linux: ``libTdxAiData.so``)提供行情、基础信息、专业数据、分笔与实时订阅能力,
|
|
5
|
+
对齐 tqcenter 命名,不依赖 tqcenter / TPyth / 通达信客户端。
|
|
6
|
+
|
|
7
|
+
用法::
|
|
8
|
+
|
|
9
|
+
from tdxaidata import tqs
|
|
10
|
+
|
|
11
|
+
snap = tqs.get_market_snapshot("600000.SH", ["Name", "Price", "Close"])
|
|
12
|
+
print(snap)
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
from .tqserver import TqsError, tqs
|
|
16
|
+
|
|
17
|
+
__all__ = ["tqs", "TqsError"]
|
|
18
|
+
__version__ = "1.0.0"
|