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.0

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.0
File Size Uploaded Provenance Actions
mktpack-0.1.0.tar.gz 110.2 kB Without provenance Details for mktpack-0.1.0.tar.gz

Built distributions (wheels)

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

Total release size: 9.2 MB

Release files / mktpack-0.1.0.tar.gz

Download URL mktpack-0.1.0.tar.gz
Size 110.2 kB
Tags Source
SHA-256 checksum
How to use checksums
843cfe5dc955c5967bf3492cdff7b8b4c71e282dfc814263f90331c910d49c08
BLAKE2b-256 checksum
How to use checksums
3fcb65d47902f1f50bb4e3ff11064f2a8c50721dbff93ff06b5b920c04dfb612
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.0-cp312-abi3-win_amd64.whl

Download URL mktpack-0.1.0-cp312-abi3-win_amd64.whl
Size 4.9 MB
Tags CPython 3.12 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
c3db0f97fd58eb81b43a50e35358ca039293737f1a9a0c1a62395f5b53f974f7
BLAKE2b-256 checksum
How to use checksums
f73aa1147435dd896ef8821f6f885ef22ff4847c3bf0537475378440cbf9eb32
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.0-cp312-abi3-manylinux_2_28_x86_64.whl

Download URL mktpack-0.1.0-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
c4545dc464804e55210fa9a7347fbeb401f0b8e48cabfa844aff806e22bef69a
BLAKE2b-256 checksum
How to use checksums
6159ac481d9c1d956e31df79121f9235159d02a23cd0cd9500f2b89219863d03
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.0

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