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.1.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.1.1
File Size Uploaded Provenance Actions
mktpack-0.1.1.tar.gz 116.7 kB Without provenance Details for mktpack-0.1.1.tar.gz

Built distributions (wheels)

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

Total release size: 9.3 MB

Release files / mktpack-0.1.1.tar.gz

Download URL mktpack-0.1.1.tar.gz
Size 116.7 kB
Tags Source
SHA-256 checksum
How to use checksums
5ee88942b21f6e30c5ec317654eb8e95ed453b8a33c0bc36619b7db819016646
BLAKE2b-256 checksum
How to use checksums
c6b682df974d9b0e9128270b817473f8ba37407078d3248c9be3ce95a7c35a7a
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.1.1-cp312-abi3-win_amd64.whl

Download URL mktpack-0.1.1-cp312-abi3-win_amd64.whl
Size 4.9 MB
Tags CPython 3.12 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
3e9767afd8ac2d1ff282048ed520ac787f928416f4f9dc91e2233d48ded233dd
BLAKE2b-256 checksum
How to use checksums
f0d29d9ac651c401602c33cb71f8025b59ca0a061ae9d8a1cc0c12f62fb45ff9
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.1.1-cp312-abi3-manylinux_2_28_x86_64.whl

Download URL mktpack-0.1.1-cp312-abi3-manylinux_2_28_x86_64.whl
Size 4.2 MB
Tags CPython 3.12 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
f97265fd4d6729bdd453b6eb2313f24897568e6aaed4ebc217c7b7dc286601a7
BLAKE2b-256 checksum
How to use checksums
ad58ff3e0ebb32edac32557dd811306984f83214d02c85922ce53887bb492484
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.1.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