Skip to main content

xoms-rs

An unofficial, high-reliability market data client compatible with Primary API / xOMS endpoints, built with a pure Rust core (xoms-core) and ABI3 Python bindings (pyxoms).

Important — Legal & Non-Affiliation Notice: xoms-rs and pyxoms are independent open-source software projects with no affiliation, endorsement, or sponsorship from Primary S.A., A3 Mercados (Matba Rofex), or BYMA.

  • Market Data Only: Order routing is intentionally omitted until an explicit order-routing ADR.
  • Bring Your Own Credentials: Users are solely responsible for complying with their broker/ALyC terms, exchange market data licensing, and Primary homologation requirements.
  • Zero Real Market Data: This repository strictly forbids committing or pasting real exchange quotes, catalogs, tokens, or account numbers.

Installation

pip install pyxoms
# or with uv
uv add pyxoms

Key Features

  • Memory-safe Rust core + pure rustls: #![forbid(unsafe_code)] in xoms-core, HTTPS-only REST (redirects disabled), wss://-only WebSockets, and openssl-sys banned via cargo-deny.
  • GIL-releasing Python ABI3 (>=3.12): Background Tokio WebSocket actor, single-wheel ABI3 compatibility across Python 3.12–3.14, and frozen Python objects.
  • Financial precision: Exact rust_decimal::Decimal / decimal.Decimal for prices, sizes, and volumes (never f64), plus UTC timestamps/dates.
  • Market structure correctness: Preserves separate BYMA settlements (CI, 24hs, 48hs) in BymaSettlementQuotes, supports BymaOther suffixes (72hs, T0, T1, T2, CN, PL), models PESOS / DOLAR / CABLE caucion term curves (1..=365 days), and enforces strict outbound smd key ordering (type first, symbol before marketId).
  • Resilient Sans-I/O WebSocket engine: Zero-f64 exponential backoff+jitter, 50-minute monotonic /auth/getToken TTL refresh, heartbeat/idle checks, stateful field-merging Conflator, and anti-batch-poisoning symbol pruning.
  • Two delivery modes: Conflated latest-state delivery by default, or an opt-in bounded, lossless, ordered journal that fails fast with a typed error instead of dropping updates.

Quick Usage (Python asyncio)

import asyncio
from pyxoms import DeliveryMode, InstrumentCatalog, MarketDataClient, MarketDataEntry, XomsConfig


async def main() -> None:
    # Reads XOMS_ENV (REMARKET | LIVE | LIVE:<BROKER>), XOMS_API_URL, XOMS_WS_URL, XOMS_USER, XOMS_PASSWORD
    cfg = XomsConfig.from_env()
    client = MarketDataClient(cfg)

    # Fetch and cache the catalog losslessly without rebuilding dicts in Python
    catalog = await client.fetch_catalog()
    cached_json = catalog.to_json()
    reloaded = InstrumentCatalog.parse_json(cached_json)
    print(f"Loaded {len(reloaded)} instruments")

    # Conflated WebSocket stream (example synthetic symbols)
    async with client.stream(["MERV - XMEV - SYNA - 24hs", "MERV - XMEV - PESOS - 1D"]) as stream:
        dirty = await stream.wait_dirty(timeout_ms=2_000)
        for quote in dirty:
            bid = quote.best_bid.price if quote.best_bid else None
            print(quote.instrument.symbol, bid)

        byma = stream.byma_settlements("SYNA")
        pesos_curve = stream.caucion_curve("PESOS")
        print(byma.t24h, pesos_curve.shortest())

    # Journal delivery: every update in arrival order, bounded and fail-fast
    async with client.stream(["SYNA"], delivery=DeliveryMode.journal(50_000)) as stream:
        async for batch in stream.journal(max_entries=1_024):
            for entry in batch:
                if isinstance(entry, MarketDataEntry):
                    print(entry.sequence, entry.delta.last, entry.state.best_bid)
                else:  # SessionBoundary: "connected" / "disconnected"
                    print("session", entry.kind, entry.at)


asyncio.run(main())

Quick Path

Prerequisites: Rust stable (rustfmt, clippy), cargo-deny, and uv (Python >= 3.12).

# 1. Verify the Rust workspace
cargo test --workspace
cargo clippy --workspace --all-targets -- -D warnings
cargo deny check

# 2. Build the local Python extension (with offline testing feature) and run Python checks
uv sync --group dev --no-install-project
uv run --no-sync maturin develop --features testing
uv run --no-sync ruff check . && uv run --no-sync ruff format --check .
uv run --no-sync mypy
uv run --no-sync pytest -q
uv run --no-sync python examples/adapter_pattern.py

# 3. Run offline synthetic benchmarks
cargo bench -p xoms-core --bench market_data_bench -- --warm-up-time 0.2 --measurement-time 0.5
uv run --no-sync python benchmarks/bench_pyxoms.py
uv run --no-sync python benchmarks/compare_pure_python.py

# 4. Mirror CI locally across Rust + Python 3.12 & 3.14 (committed HEAD)
./scripts/ci-local.sh

# 5. Optional manual reMarkets smoke check (outside CI; requires local .env with XOMS_ENV=REMARKET)
cargo test -p xoms-core --test remarkets_smoke -- --ignored --nocapture
uv run python examples/remarkets_smoke.py

Building a Wheel

uv sync --group dev
uv run maturin build --release --out dist
uv pip install dist/pyxoms-*.whl

Synthetic Benchmark Snapshot

Measured offline via uv run python benchmarks/compare_pure_python.py on Linux x86_64 (CPython 3.14, --release ABI3 wheel) against an equivalent pure-Python baseline (stdlib json + Decimal):

Workload (100% synthetic) Pure Python (json + Decimal) pyxoms (Rust ABI3) Improvement
Catalog parse (1,600 instruments ×10) 7.20 ms median 2.72 ms median 2.6x faster
Batch parse + conflate (20k msgs) 114,991 msg/s 489,031 msg/s 4.3x throughput
Async burst & event-loop jitter (10k frames) 112,874 msg/s (p99 196.3 µs) 372,305 msg/s (p99 2.1 µs) 3.3x (max_stall 0.21 ms → 0.04 ms)
Python heap peak (tracemalloc, 10k frames) 79.0 KiB 24.7 KiB 3.2x smaller

Architecture

Component Role Stack
crates/xoms-core Pure Rust domain types, config guards, protocol codecs, and transport traits Rust (rustls, #![forbid(unsafe_code)])
crates/pyxoms Thin PyO3 ABI3 (>=3.12) FFI layer releasing the GIL Rust (pyo3) + maturin
python/pyxoms Typed Python package with PEP 561 .pyi stubs Python >= 3.12

See ADR 0001 for the rationale behind the workspace split, TLS backend, and financial precision choices.

Environment Profiles & Stream Scope

  • Fail-closed Environment profiles: XomsConfig / XOMS_ENV accepts only "REMARKET", "LIVE", or "LIVE:<BROKER>" (e.g. "LIVE:ECO"). Unprefixed broker names (such as "ECO") are rejected so mistyped configs never route silently to live endpoints.

  • Delivery modes: MarketDataStream merges every partial Md delta into per-instrument state in both modes; only delivery differs.

    Mode Use it for Read with When Python falls behind
    DeliveryMode.conflated() (default) Watchlists, UI, quoting: only the latest state matters wait_dirty, drain_dirty, async for batch in stream Intermediate updates are coalesced; nothing fails
    DeliveryMode.journal(capacity) Recording, backtests, tick-level strategies: every update matters wait_journal, drain_journal, async for batch in stream.journal() Fails fast with JournalOverflowError and closes the stream; no update is dropped silently

    Journal batches hold MarketDataEntry (sequence, received_at, raw delta, merged state) and SessionBoundary ("connected" / "disconnected") entries. Sequences start at 1 and are contiguous; updates published while the socket is down cannot be recovered, so boundaries mark every discontinuity. In MarketDataDelta, bids / offers are None when the frame omitted that side and () when it cleared it.

    Sizing capacity: it counts pending entries, and each entry holds the delta plus a copy of the merged state. Size it for the worst burst between two drains, not the average rate: a synthetic burst can fill the journal before Python reads once. Watch journal_len and journal_high_watermark in production. Entries accepted before an overflow are still returned in order; the next read after them raises JournalOverflowError (capacity, last_accepted_sequence, product). Each mode raises ConfigError on the other mode's read methods. See ADR 0003.

Roadmap

  • Stage 0 (Done): OSS governance, dual license, cargo-deny, CI parity (scripts/ci-local.sh), workspace skeleton, and AI integration layer.
  • Stage 1 (Done): Domain & protocol (config environment guards, SecretString, Clock, BymaSettlementQuotes, strict smd field ordering, dual Md parser with rust_decimal and jiff::Timestamp, and status: ERROR missing-product parser).
  • Stage 2 (Done): Async REST client (auth /auth/getToken with 50m monotonic TTL, ReqwestTransport over rustls, InstrumentCatalog, and RestClient with 401 refresh and bounded retries).
  • Stage 3 (Done): Sans-I/O WebSocket engine (WsEngine / WsClient), WsTransport + TungsteniteTransport (rustls) / FakeWsTransport, zero-f64 backoff+jitter, caucion term-curve domain, stateful field-merging Conflator, and anti-batch-poisoning isolation.
  • Stage 4 & v0.1.3 (Done): Full pyxoms ABI3 async/conflated Python API (MarketDataClient, background-Tokio MarketDataStream, frozen Decimal/UTC domain objects, lazy cancel-safe asyncio bridge), criterion/Python benchmarks, CABLE cauciones, BymaOther suffixes, configurable WsConfig.subscription_entries, lossless InstrumentCatalog.to_json(), single-pass conflation, cancel-safe WsClient, structured Python error attributes, and production ABI3 PyPI packaging.
  • Stage 5 & v0.2.0 (Current): Opt-in journal delivery (DeliveryMode.journal, JournalOverflowError, session boundaries) alongside conflated delivery, with Stage 5 property, simulation, and FFI tests (ADR 0003).

AI-Friendly Integration

If you are using an AI coding agent to integrate xoms-rs or pyxoms into another repository:

License

Dual-licensed under MIT OR Apache-2.0 (LICENSE-MIT, LICENSE-APACHE).

Documentación en español disponible en README.es.md.

Metadata

Release files for pyxoms 0.2.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 pyxoms 0.2.0
File Size Uploaded Provenance Actions
pyxoms-0.2.0.tar.gz 154.0 kB With provenance Details for pyxoms-0.2.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for pyxoms 0.2.0
File Actions
pyxoms-0.2.0-cp312-abi3-win_amd64.whl CPython 3.12 abi3 Windows x86-64 Details for pyxoms-0.2.0-cp312-abi3-win_amd64.whl
pyxoms-0.2.0-cp312-abi3-manylinux_2_28_x86_64.whl CPython 3.12 abi3 Linux glibc 2.28+ x86-64 Details for pyxoms-0.2.0-cp312-abi3-manylinux_2_28_x86_64.whl
pyxoms-0.2.0-cp312-abi3-manylinux_2_28_aarch64.whl CPython 3.12 abi3 Linux glibc 2.28+ ARM64 Details for pyxoms-0.2.0-cp312-abi3-manylinux_2_28_aarch64.whl
pyxoms-0.2.0-cp312-abi3-macosx_11_0_arm64.whl CPython 3.12 abi3 macOS 11.0+ ARM64 Details for pyxoms-0.2.0-cp312-abi3-macosx_11_0_arm64.whl
pyxoms-0.2.0-cp312-abi3-macosx_10_12_x86_64.whl CPython 3.12 abi3 macOS 10.12+ x86-64 Details for pyxoms-0.2.0-cp312-abi3-macosx_10_12_x86_64.whl

Total release size: 15.1 MB

Release files / pyxoms-0.2.0.tar.gz

Download URL pyxoms-0.2.0.tar.gz
Size 154.0 kB
Tags Source
SHA-256 checksum
How to use checksums
ace145dcff640677a5ae0965da28c1e178ffeae50ea1e95b418e3d21f113d432
BLAKE2b-256 checksum
How to use checksums
030b2f3988519be612a26c55ddea314defb7a953c39c0a5e9d2c7371d1789e80
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 30, 2026.

Transparency log

Release files / pyxoms-0.2.0-cp312-abi3-win_amd64.whl

Download URL pyxoms-0.2.0-cp312-abi3-win_amd64.whl
Size 2.9 MB
Tags CPython 3.12 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
718fce708c87072ce5f90f2456b618f93682049f9035950eddc918089e7ce3d3
BLAKE2b-256 checksum
How to use checksums
9b13e00f67c7337d2dd79d53d5f0c40c3aed092bc12aa3bcf80b7756862fba81
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 30, 2026.

Transparency log

Release files / pyxoms-0.2.0-cp312-abi3-manylinux_2_28_x86_64.whl

Download URL pyxoms-0.2.0-cp312-abi3-manylinux_2_28_x86_64.whl
Size 3.1 MB
Tags CPython 3.12 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
c3e6e6dce0c15c139b857e2ac77e7f926b98a1df184b6dc4b754e6f27b20fe68
BLAKE2b-256 checksum
How to use checksums
f1052e671f7ad2a6ef25647b36e1d0d31a1c48fac459d67065354573ce4a8e3a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 30, 2026.

Transparency log

Release files / pyxoms-0.2.0-cp312-abi3-manylinux_2_28_aarch64.whl

Download URL pyxoms-0.2.0-cp312-abi3-manylinux_2_28_aarch64.whl
Size 3.0 MB
Tags CPython 3.12 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
2f6a91fb5cde951d190ed59499cd060f869043e1f8cde087bf99046b7805c5ad
BLAKE2b-256 checksum
How to use checksums
d62b69133407bb8115345389a190426ebf0a34940c8e9a2e77d7d9519756b2f8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 30, 2026.

Transparency log

Release files / pyxoms-0.2.0-cp312-abi3-macosx_11_0_arm64.whl

Download URL pyxoms-0.2.0-cp312-abi3-macosx_11_0_arm64.whl
Size 2.9 MB
Tags CPython 3.12 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
3b3ef5cfd2268715bd61a438bd24fba2e9c6c98341cd47560bd39c35744488ef
BLAKE2b-256 checksum
How to use checksums
34e553c84f0c386d9acc76fe22603ebfb67f3f8705b6561329e102542ac296e0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 30, 2026.

Transparency log

Release files / pyxoms-0.2.0-cp312-abi3-macosx_10_12_x86_64.whl

Download URL pyxoms-0.2.0-cp312-abi3-macosx_10_12_x86_64.whl
Size 3.1 MB
Tags CPython 3.12 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
23b374d64ed07946b3d9258d51830bf25c11ed59f715e64f545ce96bf2f36599
BLAKE2b-256 checksum
How to use checksums
84567a95abdbf0114af97658c4fec87fdac3f2cd3047c3b42e59067ac473a16e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 30, 2026.

Transparency log

Security for pyxoms 0.2.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.

Full provenance

All 6 files in this release have been uploaded with provenance metadata.

Select from 6 files

Attestation for pyxoms-0.2.0.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 Nov 30, 2026.

Transparency log

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