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
- The domain core is pure.
pycustodian.domainimports 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. - 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.
- Money is
Decimal, neverfloat.
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
Metadata
Release files for pycustodian 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pycustodian-0.0.2.tar.gz | 104.9 kB | With provenance | Details for pycustodian-0.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pycustodian-0.0.2-py3-none-any.whl | Python 3 | none | any | Details for pycustodian-0.0.2-py3-none-any.whl |
Total release size: 159.1 kB
Release files / pycustodian-0.0.2.tar.gz
| Download URL | pycustodian-0.0.2.tar.gz |
|---|---|
| Size | 104.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
06ced650a855d6e7e38f2bfb024ed20cfaec20ca52a93e848221cc354d3b0dda
|
|
BLAKE2b-256 checksum How to use checksums |
db031913255c1de82ae7395b7cd6519075d4c0e3c313ae649a161630779d8b20
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
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 Jun 13, 2026.
Transparency logRelease files / pycustodian-0.0.2-py3-none-any.whl
| Download URL | pycustodian-0.0.2-py3-none-any.whl |
|---|---|
| Size | 54.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ba9dc581e36b64f4a22a8bb47002a8f580368d28188ba8009199e1a7ca4594ec
|
|
BLAKE2b-256 checksum How to use checksums |
5a474e5ccc0ceb61b61310aed356fce63b2b9ee7e2f42839da2fbc0afbef655c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
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 Jun 13, 2026.
Transparency logSecurity for pycustodian 0.0.2
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 2 files in this release have been uploaded with provenance metadata.
Attestation for pycustodian-0.0.2.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 Jun 13, 2026.
Transparency logA 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.