Skip to main content

MktPack

高压缩、高性能的金融时序数据 C++20 读写库,提供 Python 接口和原生 mkt 命令。除了 .mkp 基础市场时序压缩格式,还提供两个适配:

  • 币安 USDT UM 永续 Kline、OI、结算资金费率和交易所信息下载
  • 中国期货 tick 导入

安装

uv add mktpack

需要 Python 3.12+。wheel 包含原生 mkt 命令。

Python 读取接口

import mktpack

market = mktpack.open('data/binance')
groups = market.describe()
symbols = market['kline'].symbols(start=20260101, end=20260201)
bars = market['kline'].read(
    symbol='BTCUSDT', start=20260101, end=20260201,
    columns=['time', 'close', 'volume'],
)
info = market['exchangeinfo']

futures = mktpack.open('data/cn_futures')
ticks = futures['tick'].read(symbol='CU2610', columns=['time', 'last_price'])

时序查询返回 Arrow Table,时间按 UTC [start,end) 筛选

币安下载

uv run mkt --root data/binance binance download --symbols BTCUSDT --start 2026-01-01 --end 2026-02-01

省略 --symbols 自动发现全部 USDT 品种。

币安下载默认使用无损编码,添加 --lossy-taker 将主动买量占比按 0.1 个百分点量化。--full 检查来源对应的本地载荷并补齐缺失数据。

导入中国期货 tick

uv run mkt --root data/cn_futures ctp-futures import path/to/ctp-mirror --symbols CU2610 --start 2026-09-01 --end 2026-10-01

镜像根目录包含 nfs_rq*/tick/future,导入按源包文件名中的交易日筛选,不写 symbols、start、end 时默认全量

打包

工具提供将零散的数据文件打包到若干个大文件的功能:

uv run mkt --root data/binance package packaged-data --max-file-size 8GiB

可用 --groups、--symbols、--start、--end 筛选.

普通数据目录和打包目录使用相同的读取接口。

开发

uv sync
just test

LLM 与 MktPack

我完成了需求和规范的整理,LLM 完成了主要代码,我负责了审查和编写部分核心代码.

库已经在实际项目投入使用


需求

Metadata

Release files for mktpack 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mktpack 0.2.1
File Size Uploaded Provenance Actions
mktpack-0.2.1.tar.gz 151.4 kB Without provenance Details for mktpack-0.2.1.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for mktpack 0.2.1
File Interpreter ABI Platform Actions
mktpack-0.2.1-cp312-abi3-win_amd64.whl CPython 3.12 abi3 Windows x86-64 Details for mktpack-0.2.1-cp312-abi3-win_amd64.whl
mktpack-0.2.1-cp312-abi3-manylinux_2_28_x86_64.whl CPython 3.12 abi3 Linux glibc 2.28+ x86-64 Details for mktpack-0.2.1-cp312-abi3-manylinux_2_28_x86_64.whl

Total release size: 12.1 MB

Release files / mktpack-0.2.1.tar.gz

Download URL mktpack-0.2.1.tar.gz
Size 151.4 kB
Tags Source
SHA-256 checksum
How to use checksums
b0f96cebe694b5129016207f4bdc47f2b5a16905e5b24b96bc37fb555570cf26
BLAKE2b-256 checksum
How to use checksums
806c27f1d25d8f319b1df4f0bd36a159265e08ef64ac599088ef704ff9df781f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Manjaro Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / mktpack-0.2.1-cp312-abi3-win_amd64.whl

Download URL mktpack-0.2.1-cp312-abi3-win_amd64.whl
Size 6.3 MB
Tags CPython 3.12 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
3b7cc38dc67d32d77ffba87677e393b11dd0759b2f61351b548d9e8623e9ae12
BLAKE2b-256 checksum
How to use checksums
f955f619b2ba7b114bdf3b1a62806610ada26b9c37e1cd899e11082c65702662
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Manjaro Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / mktpack-0.2.1-cp312-abi3-manylinux_2_28_x86_64.whl

Download URL mktpack-0.2.1-cp312-abi3-manylinux_2_28_x86_64.whl
Size 5.7 MB
Tags CPython 3.12 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
091503fc83e04dedd80d71dfce81559c44c4e062124ebcfcce4c11b13145a80e
BLAKE2b-256 checksum
How to use checksums
07e3925ca5e0b28036571ef6606d0180ee5cf05c21588d3e25df0c80e2551a81
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Manjaro Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for mktpack 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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