Skip to main content

ml4t-specs

Python 3.12-3.14 PyPI License: MIT

Shared schema and artifact contracts for the ML4T library ecosystem.

The stable support matrix is CPython 3.12 through 3.14 on Linux, macOS, and Windows. CPython 3.15 prereleases are tested on all three operating systems but are not advertised as stable until Python 3.15 is final.

What This Package Does

ml4t-specs provides the small set of shared types that multiple ML4T libraries use to describe:

  • market data column mappings and feed semantics
  • artifact metadata and storage conventions
  • lightweight YAML/JSON spec payloads

It exists so the higher-level libraries can exchange consistent contracts without re-defining the same dataclasses in multiple repos.

Today it is used by:

  • ml4t-backtest for FeedSpec and market-data execution semantics
  • ml4t-engineer for artifact metadata
  • ml4t-diagnostic for artifact and backtest-result integration
  • ml4t-models as an optional integration bridge when ml4t-specs is installed

Installation

pip install ml4t-specs

Main Types

FeedSpec

FeedSpec defines how downstream libraries should interpret a tradable price table:

  • timestamp column
  • entity column
  • price / OHLCV columns
  • quote columns
  • calendar and timezone
  • data frequency and timestamp semantics
from ml4t.specs import FeedSpec

feed = FeedSpec(
    timestamp_col="date",
    entity_col="ticker",
    close_col="settle",
    price_col="settle",
    calendar="NYSE",
    timezone="America/New_York",
    data_frequency="daily",
)

MarketDataSpec

MarketDataSpec bundles schema, semantics, and artifact metadata into one serializable object.

from ml4t.specs import ArtifactStorage, MarketDataSchema, MarketDataSemantics, MarketDataSpec

spec = MarketDataSpec(
    artifact_id="us_equities_daily",
    schema=MarketDataSchema(timestamp_col="date", entity_col="ticker", close_col="close"),
    semantics=MarketDataSemantics(calendar="NYSE", data_frequency="daily"),
    storage=ArtifactStorage(path="data/us_equities_daily.parquet"),
)

Artifact Contracts

The base artifact layer gives ML4T libraries a shared way to talk about persisted outputs:

  • ArtifactKind
  • ArtifactStorage
  • ArtifactProvenance
  • ArtifactSpec

Read And Write Spec Payloads

from ml4t.specs import read_spec_payload, write_spec_payload

write_spec_payload(spec, "market_data.yaml")
loaded = read_spec_payload("market_data.yaml")

Why This Exists

The public ML4T libraries share a few contract types at their boundaries. Keeping them here:

  • reduces duplication
  • keeps cross-library serialization consistent
  • gives backtest, modeling, engineering, and diagnostics code one shared contract vocabulary

This package is intentionally small. It is a support layer, not a full end-user workflow library.

Development

git clone https://github.com/ml4t/specs.git
cd ml4t-specs
uv sync --dev
uv run ruff check src/ tests/
uv run ty check
uv run pytest tests/ -q
uv build

License

MIT

Download files

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

Source Distribution

ml4t_specs-0.1.0.tar.gz (11.1 kB view details)

Uploaded Source

Built Distribution

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

ml4t_specs-0.1.0-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file ml4t_specs-0.1.0.tar.gz.

File metadata

  • Download URL: ml4t_specs-0.1.0.tar.gz
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for ml4t_specs-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a283030dceb30039acaf3188b508e8058075ed62fc38ef9e2fa51181f92b3d36
MD5 54e502914e81d58d9cc50f1b8762e63e
BLAKE2b-256 443d9551605c4bf3a89d107eb7ccd2fca977ee516edfd14937c40791c6cd946b

See more details on using hashes here.

Provenance

The following attestation bundles were made for ml4t_specs-0.1.0.tar.gz:

Publisher: release.yml on ml4t/specs

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

File details

Details for the file ml4t_specs-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: ml4t_specs-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for ml4t_specs-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a6e7f253a6c501d946cfdfd3d8729e94e09180012f9bec1a4f1ef9afa86d4560
MD5 84d3a71056571aa1cb61f0320d38c79d
BLAKE2b-256 f85ae808b7bfa4896211f116f2714b7cd81848865dff14621ea245c7722f907b

See more details on using hashes here.

Provenance

The following attestation bundles were made for ml4t_specs-0.1.0-py3-none-any.whl:

Publisher: release.yml on ml4t/specs

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 Sentry Error logging StatusPage Status page