Skip to main content

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_v1
  • qmt_daily_v1
  • baostock_adjust_factor_events
  • choice_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.

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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xtquant_duck-0.1.20260704.8.tar.gz (35.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xtquant_duck-0.1.20260704.8-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file xtquant_duck-0.1.20260704.8.tar.gz.

File metadata

  • Download URL: xtquant_duck-0.1.20260704.8.tar.gz
  • Upload date:
  • Size: 35.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for xtquant_duck-0.1.20260704.8.tar.gz
Algorithm Hash digest
SHA256 0510042a82b2335b22ed97ab4b8805b4a607995169092b876845c601c4008f27
MD5 f86a1f8a5a52425c3bbe1ad99e44b95a
BLAKE2b-256 3e7ad1101f8b68fd1e9fdb4be23ed6934be268f7462049671ffb589c4fd52010

See more details on using hashes here.

Provenance

The following attestation bundles were made for xtquant_duck-0.1.20260704.8.tar.gz:

Publisher: publish.yml on drunkpig/xtquant-duck

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file xtquant_duck-0.1.20260704.8-py3-none-any.whl.

File metadata

File hashes

Hashes for xtquant_duck-0.1.20260704.8-py3-none-any.whl
Algorithm Hash digest
SHA256 51f83c47697376445d24325c9664768e86a4c888fabb2a78e244e500536ca546
MD5 c87991641256bd35171c152d6d803b97
BLAKE2b-256 2ab6ab9362a9e9c059af8d20457b091f1e366f22c6192dcb03cc15ac6d70b707

See more details on using hashes here.

Provenance

The following attestation bundles were made for xtquant_duck-0.1.20260704.8-py3-none-any.whl:

Publisher: publish.yml on drunkpig/xtquant-duck

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.20260704.8 This release

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