Skip to main content

wire — a broker-neutral order-intent wire schema

wire

A tiny, broker-neutral order-intent wire schema for a producer/consumer transport (Redis Streams or anything else). A strategy process produces OrderIntents; an executor process consumes them and reports back with ResultEvents. wire is the vendor-free contract both sides agree on: pure stdlib dataclasses with explicit JSON (de)serialisation, no broker, transport, or networking imports.

Install

pip install dollarsmore-wire
# or
uv add dollarsmore-wire
from wire import OrderIntent, ResultEvent, IntentAction, OrderType

The distribution is dollarsmore-wire; the import package is wire.

What's in it

  • OrderIntent — an order command: OPEN / CLOSE / CANCEL, one or more IntentLegs, order type, price (positive-magnitude Decimal) with an explicit PriceEffect (DEBIT / CREDIT), time-in-force, correlation id, strategy tag.
  • OpenBracketIntent — an entry plus a pre-staged take-profit as one OTO bracket.
  • ResultEvent — the executor's reply: ACCEPTED / REJECTED / FILLED / CANCELLED / ERROR, broker order id, fill price, detail.
  • Enums: IntentAction, LegAction, OptionType, OrderType, PriceEffect, ResultStatus.

Every type round-trips through .to_wire() / .from_wire() plain dicts, so the transport only ever moves JSON.

Redis-Streams transport (wire.transport)

wire.transport is the shared Redis-Streams envelope both producer and consumer agree on — stream names (orders:intents / :results / :deadletter), the consumer group, and pure encode_* / decode_* helpers that wrap a wire object in a {kind, payload} dict. It has no redis import (stdlib + wire only); the caller drives its own redis client (client.xadd(INTENTS_STREAM, encode_bracket(intent))). Keeping it here stops producer and consumer drifting on the wire format.

Versioning

WIRE_VERSION is stamped into every serialised payload (the v field). Bump it on any breaking change to the wire shape so producer and consumer can detect a mismatch.

Design rules

  • Stdlib only — no third-party dependencies, ever.
  • Money is a positive-magnitude Decimal plus an explicit PriceEffect; never a signed float.
  • Times are ISO 8601 strings on the wire; enums travel by value.

from_wire is the contract boundary and refuses anything it cannot honour, always with a ValueError so a consumer can dead-letter on one exception type:

  • Money is a JSON string holding a plain decimal literal, never a JSON number. {"price": 1.60} would round through binary float and decode as 1.6000000000000000888..., which is what the broker would then be quoted. Digits with at most one point: no sign, no exponent, no underscores, no surrounding whitespace, so NaN, Infinity, -0.00, 1e3 and 1_0 are all refused.
  • Money sits at or below MONEY_CEILING (1,000,000, exported). A premium past it is a corrupt print rather than a price, and to_wire refuses it BEFORE expanding to fixed point: 1E+9999999 is twelve bytes in and ten megabytes out.
  • strike and quantity are JSON integers, not floats, strings or booleans: 2.9 must not silently become 2 contracts.
  • quantity sits in QUANTITY_FLOOR..QUANTITY_CEILING (1 to 99), both exported.
  • A LIMIT order carries both price and price_effect; a limit with no limit price is refused rather than passed on as the string "None".
  • v is an integer no greater than WIRE_VERSION.

to_wire enforces the money rule too, so a producer fails on its own bad value instead of learning about it as a dead-letter in another process.

Develop

uv sync
uv run pytest
uv run ruff check .
uv run mypy wire tests

Metadata

Release files for dollarsmore-wire 0.6.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 dollarsmore-wire 0.6.0
File Size Uploaded Provenance Actions
dollarsmore_wire-0.6.0.tar.gz 389.9 kB Without provenance Details for dollarsmore_wire-0.6.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dollarsmore-wire 0.6.0
File Interpreter ABI Platform Actions
dollarsmore_wire-0.6.0-py3-none-any.whl Python 3 none any Details for dollarsmore_wire-0.6.0-py3-none-any.whl

Total release size: 399.1 kB

Release files / dollarsmore_wire-0.6.0.tar.gz

Download URL dollarsmore_wire-0.6.0.tar.gz
Size 389.9 kB
Tags Source
SHA-256 checksum
How to use checksums
28c84a236791ac259a05044a8a4aa324c8dd4e70b2af5e1cb2eaefbc214d4e1a
BLAKE2b-256 checksum
How to use checksums
3114913d83a65fdf9017978db6e30109b953488fc4fb5c7fbd2d7171e954b88c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / dollarsmore_wire-0.6.0-py3-none-any.whl

Download URL dollarsmore_wire-0.6.0-py3-none-any.whl
Size 9.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3e987432b18dfd31002362437c6f13a4adba0023fe04b52e08a919978182222a
BLAKE2b-256 checksum
How to use checksums
a32dc9cb5d003981a1f8bcf7ff3d89ba288bc4dbc7b590e0e47d78c832cf9e99
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for dollarsmore-wire 0.6.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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