Skip to main content

Canonical reference data for Money Ex Machina.

Project description

mxm-refdata

Version License Python Checked with pyright

Reference-data ontology and contract-generation framework for the Money Ex Machina (MXM) ecosystem.

mxm-refdata provides deterministic definitions of futures products, futures contracts, periods, lifecycle dates, and trading-calendar relationships. It materialises these definitions into a queryable reference-data store and exposes them through a typed Python API.

The package is intended to answer questions such as:

What futures products exist?

What contracts should exist for a given product?

When does a contract become active?

When is the last trading day?

Which contract is active on a given date?

without depending on any market-data vendor.

Purpose

mxm-refdata defines financial reference objects and the rules by which they are constructed.

For example:

cme_gbp_futures.Mar-2032

is not stored as a static object.

Instead it is deterministically derived from:

  • a product specification,
  • listing rules,
  • period definitions,
  • period-cycle membership,
  • trading-calendar semantics,
  • and lifecycle rules.

This allows downstream systems to reason about contracts independently of any particular data vendor.

Observed prices, quotes, trades, and exchange events belong to separate packages such as mxm-marketdata.

Architecture

mxm-refdata consists of four conceptual layers.

Product specifications

Human-authored definitions describing:

  • products,
  • contract sizes,
  • listing rules,
  • lifecycle rules,
  • trading calendars,
  • and valid period structures.

Currently these specifications are sourced from bundled CSV files.

Future versions are expected to source them from a dedicated mxm-refdata-source repository.

Deterministic generation

Generation services construct:

  • periods,
  • period cycles,
  • futures products,
  • futures contracts,
  • first day of interest,
  • and last trading day.

Materialised reference store

Generated entities are persisted into a reference-data database.

Current implementation:

SQLite

Future deployments may use PostgreSQL through the same service layer.

Query API

The materialised reference universe is exposed through:

  • RefDataAPI
  • operational CLI commands
  • downstream MXM services

Design Principles

Explicit construction

mxm-refdata no longer discovers configuration implicitly.

Services are constructed from fully resolved configuration data.

config = normalise_refdata_config_data(...)
api = RefDataAPI.from_config_data(config)

rather than:

api = RefDataAPI()

Derived state

The reference database is deterministic derived state.

Given:

  • product specifications,
  • lifecycle rules,
  • trading-calendar semantics,
  • and a contract materialisation horizon,

the database can be recreated from scratch.

Separation of concerns

The package distinguishes between:

Product definitions
Contract generation
Trading-calendar access
Reference-data storage
Query APIs

while exposing a unified operational interface.

Installation

git clone https://github.com/moneyexmachina/mxm-refdata.git
cd mxm-refdata
poetry install

CLI Usage

The CLI is intentionally explicit.

Create a reference database:

mxm-refdata rebuild \
  --db-url sqlite:////tmp/mxm-refdata.db \
  --contract-start-date 2024-01-01 \
  --contract-end-date 2026-12-31

List products:

mxm-refdata products \
  --db-url sqlite:////tmp/mxm-refdata.db

Inspect contract coverage:

mxm-refdata coverage \
  --db-url sqlite:////tmp/mxm-refdata.db

Run operational smoke checks:

mxm-refdata smokecheck \
  --db-url sqlite:////tmp/mxm-refdata.db

Future MXM applications are expected to provide higher-level runtime configuration so that users can invoke commands without repeatedly specifying database locations.

Python API

from datetime import date

from mxm.refdata import RefDataAPI

api = RefDataAPI.from_config_data(
    {
        "SQL_DB_URL": "sqlite:////tmp/mxm-refdata.db",
    }
)

products = api.get_all_products()

contracts = api.get_contracts_for_product(
    "cme_gbp_futures",
)

active_contracts = api.get_active_contracts(
    as_of_date=date(2026, 5, 1),
)

Configuration

The primary configuration fields are:

SQL_DB_URL

REFDATA_DB_MODE

REFDATA_CONTRACT_START_DATE
REFDATA_CONTRACT_END_DATE

Buildable mode

In buildable mode:

REFDATA_DB_MODE=buildable

the database is treated as deterministic derived state.

If the database is empty, mxm-refdata may automatically materialise the configured reference universe.

This mode is intended for:

  • development,
  • CI,
  • local experimentation,
  • and bootstrap workflows.

Managed mode

In managed mode:

REFDATA_DB_MODE=managed

automatic materialisation is disabled.

The reference database must be created and maintained explicitly.

This mode is intended for operational deployments.

Development

Install dependencies:

poetry install

Run the full validation suite:

make check

Repository compliance:

mxm-foundry check .

Documentation

docs/design.md

Roadmap

v0

  • Futures product definitions
  • Deterministic futures contract generation
  • Trading-calendar integration
  • Period and period-cycle models
  • Materialised reference-data store
  • Typed Python API
  • Operational CLI
  • Smoke-check framework

v1

  • Expanded futures coverage
  • Richer lifecycle-rule models
  • Explicit calendar abstractions
  • Stronger operational tooling
  • Improved ontology documentation

v2

  • ETF support
  • FX support
  • Historical rule evolution
  • Governance and reconciliation workflows
  • Integration with future MXM calendar services
  • Multi-venue reference-data management

License

MIT License. See LICENSE.

Project details


Download files

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

Source Distribution

mxm_refdata-0.4.0.tar.gz (39.8 kB view details)

Uploaded Source

Built Distribution

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

mxm_refdata-0.4.0-py3-none-any.whl (57.0 kB view details)

Uploaded Python 3

File details

Details for the file mxm_refdata-0.4.0.tar.gz.

File metadata

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

File hashes

Hashes for mxm_refdata-0.4.0.tar.gz
Algorithm Hash digest
SHA256 9cbc292e169be8d0850e6c8aeb319b3c047f0b3f17a80f54642b5db2561ec0c0
MD5 9b1b563c5da9f77034550c093b11249f
BLAKE2b-256 94b24be086c2481ae621da65f08b5d212b0382b43e41688de43a9f3ec864fa71

See more details on using hashes here.

Provenance

The following attestation bundles were made for mxm_refdata-0.4.0.tar.gz:

Publisher: release.yml on moneyexmachina/mxm-refdata

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

File details

Details for the file mxm_refdata-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: mxm_refdata-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 57.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mxm_refdata-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bf7e5479754600e5f284f89f607c42f1882743bee2bd2ec84d61f43ce0d0813b
MD5 b0570ec09bb43e4fd6d351502ceeff1f
BLAKE2b-256 5578dd5d181fa628a2746aea501f5521516190dabc5d918a8dcf60aff4097c94

See more details on using hashes here.

Provenance

The following attestation bundles were made for mxm_refdata-0.4.0-py3-none-any.whl:

Publisher: release.yml on moneyexmachina/mxm-refdata

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

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page