Skip to main content

Event-sourced double-entry book of record for trading and wealth platforms

Project description

pycustodian

The book of record for trading and wealth platforms.

pycustodian is the single, durable source of truth for positions, cost basis, cash, and P&L. It ingests fills, records them in an event-sourced double-entry journal, and serves positions, exposure, current weights, and NAV to the rest of a platform (risk, optimization, dashboards).

It is a service built around a pure, extractable domain core (hexagonal architecture): the accounting logic in pycustodian.domain is I/O-free and deterministic; persistence (SQL event store), transport (FastAPI), and live ingestion (Kafka) are adapters around it.

Why it exists

Decisioning, risk, and execution can all be stateless or transient. The book of record cannot: it must be the one authoritative, always-consistent copy of the truth, with transactional integrity and exactly-once fill ingestion. That makes it a service — but its accounting math stays a clean, testable library at the core.

Design rules

  1. The domain core is pure. pycustodian.domain imports no infrastructure (enforced by an import-linter contract). It can be extracted into a standalone package the day a second consumer (e.g. a backtester) needs the math.
  2. The journal is append-only. Positions, cash, P&L, and NAV are projections folded from the immutable transaction log. Corrections are reversing entries, never mutations — giving a full audit trail and point-in-time replay.
  3. Money is Decimal, never float.

Status

Early foundation. The pure domain core (double-entry journal, FIFO/LIFO/HIFO/ AVERAGE cost basis, projections, valuation, performance) and its test suite are in place. Persistence, application use cases, the API, Kafka ingest, and family integrations follow.

Install

pip install pycustodian                 # core (pure domain + config + CLI)
pip install "pycustodian[db,api,kafka]" # + durable store, HTTP service, live ingest

License

MIT

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

pycustodian-0.0.2.tar.gz (104.9 kB view details)

Uploaded Source

Built Distribution

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

pycustodian-0.0.2-py3-none-any.whl (54.2 kB view details)

Uploaded Python 3

File details

Details for the file pycustodian-0.0.2.tar.gz.

File metadata

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

File hashes

Hashes for pycustodian-0.0.2.tar.gz
Algorithm Hash digest
SHA256 06ced650a855d6e7e38f2bfb024ed20cfaec20ca52a93e848221cc354d3b0dda
MD5 508609997e919fee8c9b28ea436a21a2
BLAKE2b-256 db031913255c1de82ae7395b7cd6519075d4c0e3c313ae649a161630779d8b20

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycustodian-0.0.2.tar.gz:

Publisher: publish.yml on optophi/pycustodian

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

File details

Details for the file pycustodian-0.0.2-py3-none-any.whl.

File metadata

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

File hashes

Hashes for pycustodian-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ba9dc581e36b64f4a22a8bb47002a8f580368d28188ba8009199e1a7ca4594ec
MD5 57b53d4330e9a6324c6611470a07f028
BLAKE2b-256 5a474e5ccc0ceb61b61310aed356fce63b2b9ee7e2f42839da2fbc0afbef655c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycustodian-0.0.2-py3-none-any.whl:

Publisher: publish.yml on optophi/pycustodian

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