xtquant-duck
DuckDB-backed local mock implementation of selected xtquant APIs.
The goal is to let research code switch between real QMT xtquant and a local
DuckDB-backed mock by changing only the import. QMT semantics are the canonical
reference; unsupported mock behavior raises NotImplementedError instead of
silently returning placeholder data.
Install
uv pip install xtquant-duck
For local development:
git clone git@github.com:drunkpig/xtquant-duck.git
cd xtquant-duck
uv sync --all-extras --dev
Basic Usage
Set the DuckDB database path:
$env:QMT_MOCK_DUCKDB = "C:\data-tick\duckdb\qmt_mock.duckdb"
Use the mock package as an xtquant-compatible module:
import xtquant_duck as xtquant
xtdata = xtquant.xtdata
data = xtdata.get_market_data_ex(
field_list=["time", "open", "high", "low", "close", "volume"],
stock_list=["600036.SH"],
period="1d",
start_time="20220101",
end_time="20251231",
dividend_type="front_ratio",
)
The packaged qmt_data_layer module is kept for database build and validation
tools. Strategy code should use the xtquant_duck API above so switching back
to real miniQMT only changes the import.
Default database path is C:\data-tick\duckdb\qmt_mock.duckdb; override it with
QMT_MOCK_DUCKDB.
Documentation
See docs/MOCK_XTQUANT_API.md for supported APIs, parameters, return shapes, and strict unsupported behavior.
The production DuckDB file uses QMT-canonical tables qmt_tick_v1 and
qmt_daily_v1; legacy raw_* tables are retained only as rebuild/audit inputs.
Runtime Data Boundary
Installed runtime APIs are only allowed to read canonical QMT-semantics tables:
qmt_tick_v1qmt_daily_v1baostock_adjust_factor_eventschoice_sse50_constituents_2022_2025
raw_tick_v3 and raw_daily_v1 are source-lineage tables for offline import,
canonical rebuild, and validation scripts only. Strategy code and
xtquant_duck.xtdata must not query them directly. Unit tests scan the runtime
packages and fail if these raw table names appear there.
Canonical Rebuild
Canonical tables are rebuilt with fixed source boundaries:
- 2022-2025 tick:
D:\ticks\data-tick\sh_v3andD:\ticks\data-tick\sz_v3. - 2026 tick:
D:\百度盘分钟K10年\A50-2026. - 2022-2025 daily: vendor raw daily first, then missing code-days backfilled from corrected sh/sz tick.
- 2026 daily: derived from A50 tick.
QMT volume semantics are lots. During rebuild, sh/sz v3 688* tick and vendor
daily rows are converted from shares to lots by dividing by 100; sh/sz non-688
and A50 rows are already lots. A50 startup rows are not allowed into canonical
2022-2025 data.
uv run python scripts\rebuild_qmt_canonical_tables.py --db C:\data-tick\duckdb\qmt_mock.duckdb --rebuild --skip-indexes
Tests
uv run python -m unittest discover -s test -v
The unit tests build a temporary DuckDB database and do not read or write the default production database.
Metadata
Release files for xtquant-duck 0.1.20260705.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| xtquant_duck-0.1.20260705.9.tar.gz | 36.0 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| xtquant_duck-0.1.20260705.9-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 48.2 kB
Release files / xtquant_duck-0.1.20260705.9.tar.gz
| Download URL | xtquant_duck-0.1.20260705.9.tar.gz |
|---|---|
| Size | 36.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2a9405e028057f441a490c574f67b79a6c301676090052461ea53ceea9296cb1
|
|
BLAKE2b-256 checksum How to use checksums |
5d98af24514d5403b6f9e2c3487b3ac86d60cce95d43351417b3f20b029e88d1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 5, 2026.
Transparency logRelease files / xtquant_duck-0.1.20260705.9-py3-none-any.whl
| Download URL | xtquant_duck-0.1.20260705.9-py3-none-any.whl |
|---|---|
| Size | 12.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2db885f06ff019b2599623cfb348b279549dc3872fd03ae019f256d177dead18
|
|
BLAKE2b-256 checksum How to use checksums |
ecd839f5d7f65ac9945eeea0304bec02eacbe4fb25c090459c984315a026cef0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 5, 2026.
Transparency logSecurity for xtquant-duck 0.1.20260705.9
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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for xtquant_duck-0.1.20260705.9.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 5, 2026.
Transparency logA 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.