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.1.tar.gz (108.1 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.1-py3-none-any.whl (54.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pycustodian-0.0.1.tar.gz
  • Upload date:
  • Size: 108.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for pycustodian-0.0.1.tar.gz
Algorithm Hash digest
SHA256 c9c163945b58774f5c84494ca2d77a3263dca9b23cc8e6cd78922745bf186e42
MD5 8c5394a6dd21598fdfb87429148ae9ac
BLAKE2b-256 afc7efbd4f3f0cc2e829beb795392a7956b1808e3a67de0e28973ea32b0c8045

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pycustodian-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 54.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for pycustodian-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2166e1d9ee3e74b9a8a5b543dba48706e1468e05c9ceb977d464f50554720ca2
MD5 27fd063a7b5c557039bee14b692972e6
BLAKE2b-256 23e57b9573daf3063878000938d00beb85431458189ef73dff5695231ce61e29

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