通达信数据读取接口
运行环境
- 操作系统: Windows / MacOS / Linux 都可以运行.
- Python: 3.8 以及以上版本.
安装方法
新手建议使用
pip install -U 'mootdx2[all]'安装
PIP 安装方法
pip install mootdx2
升级安装
pip install -U mootdx2
开发环境安装
推荐使用 uv 进行开发环境管理:
# 安装 uv
curl -LsSf https://astral.sh/uv/install.sh | sh
# 克隆代码
git clone https://github.com/mootdx/mootdx.git
cd mootdx
# 同步依赖
uv sync
# 运行测试
uv run pytest
使用说明
以下只列举一些例子, 详细说明请查看在线文档: https://www.mootdx.com
通达信离线数据读取
from mootdx2.reader import Reader
# market 参数 std 为标准市场(就是股票), ext 为扩展市场(期货,黄金等)
# tdxdir 是通达信的数据目录, 默认按平台: Windows C:/new_tdx, macOS ~/new_tdx, Linux ~/.local/share/new_tdx
# 不传 tdxdir 时走平台默认, 也可按需指定
reader = Reader.factory(market='std', tdxdir='C:/new_tdx')
# 读取日线数据
reader.daily(symbol='600036')
# 读取分钟数据
reader.minute(symbol='600036')
# 读取时间线数据
reader.fzline(symbol='600036')
# 读取除权除息数据 (XDXR, 走 24h 缓存, 首次需联网)
reader.xdxr(symbol='600036')
通达信线上行情读取
from mootdx2.quotes import Quotes
# 标准市场
client = Quotes.factory(market='std', multithread=True, heartbeat=True)
# k 线数据
client.bars(symbol='600036', frequency=9, offset=10)
# 指数
client.index(symbol='000001', frequency=9)
# 分钟
client.minute(symbol='000001')
通达信财务数据读取
from mootdx2.affair import Affair
# 远程文件列表
files = Affair.files()
# 下载单个
Affair.fetch(downdir='tmp', filename='gpcw19960630.zip')
# 下载全部
Affair.parse(downdir='tmp')
M1 mac 系统PyMiniRacer不能使用,访问: https://github.com/sqreen/PyMiniRacer/issues/143
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
mootdx2-1.1.0.tar.gz
(11.7 MB
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
mootdx2-1.1.0-py3-none-any.whl
(111.6 kB
view details)
File details
Details for the file mootdx2-1.1.0.tar.gz.
File metadata
- Download URL: mootdx2-1.1.0.tar.gz
- Upload date:
- Size: 11.7 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac6ecfb574cd6fcd88f59fc728f7daea90ab41583672fbd477bb9b048d2cb73e
|
|
| MD5 |
6d58e7a898c21ea3764030b3f57403d3
|
|
| BLAKE2b-256 |
af1faf6598ebade66d3b0f77c266bbff8e92da32cda9c14b2071092d6f994a53
|
File details
Details for the file mootdx2-1.1.0-py3-none-any.whl.
File metadata
- Download URL: mootdx2-1.1.0-py3-none-any.whl
- Upload date:
- Size: 111.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d674dc05ed14c655fe30a4341766bfdac6d81143588a787b8f971a805ecdbfe3
|
|
| MD5 |
e85a052b591c3ff572325556455735aa
|
|
| BLAKE2b-256 |
2b4df2d90ac4d0cdc86091f9bce15276486285d1e9243513eb295ff89c3745d7
|