Skip to main content

通达信数据读取接口

运行环境

  • 操作系统: 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 ~/Library/Application Support/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.0.6.tar.gz (11.6 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mootdx2-1.0.6-py3-none-any.whl (109.8 kB view details)

Uploaded Python 3

File details

Details for the file mootdx2-1.0.6.tar.gz.

File metadata

  • Download URL: mootdx2-1.0.6.tar.gz
  • Upload date:
  • Size: 11.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.15 {"installer":{"name":"uv","version":"0.9.15","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

Hashes for mootdx2-1.0.6.tar.gz
Algorithm Hash digest
SHA256 6679ac685ce2b6e2e75f0bb383a409dc9e9900666e10c239e903ba4b1c2bf029
MD5 05d344669373e5f2b3ecdd23a501e258
BLAKE2b-256 f826366fdcaeae64b8db18f903366eb20fc8fcbf66e162fefec1551db849d742

See more details on using hashes here.

File details

Details for the file mootdx2-1.0.6-py3-none-any.whl.

File metadata

  • Download URL: mootdx2-1.0.6-py3-none-any.whl
  • Upload date:
  • Size: 109.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.15 {"installer":{"name":"uv","version":"0.9.15","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

Hashes for mootdx2-1.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 0987a5f5aa6b272dbf428cd5428276ebf3208e9961a5309b27ee49b2b15c4539
MD5 2ad3491e50d8c3426e73872953693bfc
BLAKE2b-256 81a2c73f9eea31248469ea13c1bd77c1d0a77baf77d587ca345f83e0c11e481d

See more details on using hashes here.

Release history Release notifications | RSS feed

1.3.1

2 files

1.3.0

2 files

1.2.0

2 files

1.1.0

2 files

1.0.8

2 files

1.0.7

2 files

This release

1.0.6 This release

2 files

1.0.5

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page