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 ~/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.7.tar.gz (15.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.7-py3-none-any.whl (111.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mootdx2-1.0.7.tar.gz
  • Upload date:
  • Size: 15.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.7.tar.gz
Algorithm Hash digest
SHA256 0397cfc4bd5490b2fdc9bd8828f5e80192a331a4a893c996c8d08d946cd1c7bf
MD5 21b3d07b64bcd4fa6fa96fac9ef810ce
BLAKE2b-256 2e3cea57fd8bca1fb2c2102658c914973f6307943e2a1e74e9f1a6d2eb924719

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mootdx2-1.0.7-py3-none-any.whl
  • Upload date:
  • Size: 111.9 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.7-py3-none-any.whl
Algorithm Hash digest
SHA256 517da5763bf26678e69844fc687ab71097ff2515eedeedead713363fe160bb40
MD5 15530581abc45e438427c2a8ce1086a6
BLAKE2b-256 a65fe657f292a92a34da4db0a33c2459b6ad70701332d34a5dfcda863fbfdc01

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

This release

1.0.7 This release

2 files

1.0.6

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