Skip to main content

Broker-neutral order-intent wire schema for a producer/consumer Redis-Streams transport

Project description

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, 1-4 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.

Develop

uv sync
uv run pytest -q
uv run ruff check .

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

dollarsmore_wire-0.4.0.tar.gz (389.9 kB view details)

Uploaded Source

Built Distribution

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

dollarsmore_wire-0.4.0-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dollarsmore_wire-0.4.0.tar.gz
  • Upload date:
  • Size: 389.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.30 {"installer":{"name":"uv","version":"0.11.30","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}

File hashes

Hashes for dollarsmore_wire-0.4.0.tar.gz
Algorithm Hash digest
SHA256 716d29ef59fea73f25578bc36ab9212dc6308f421914733a359de24bf4738710
MD5 3575f5b980c99d8f7cd0042a0b5b0630
BLAKE2b-256 cc6deac6ad0200ca5771e447116b71eff8b660c68065ea63863fb505ec100c9d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dollarsmore_wire-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.30 {"installer":{"name":"uv","version":"0.11.30","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}

File hashes

Hashes for dollarsmore_wire-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 63a27bb50b93d21128984444c076b6fb1b04eb5999a7d06ead247aa90606eae3
MD5 42cd5e7685ee2f219f59bd1d73a87687
BLAKE2b-256 0130254755a459bb94882063c503cf161c5c6aa225ddf57699892069a94993f5

See more details on using hashes here.

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