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
- 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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
06ced650a855d6e7e38f2bfb024ed20cfaec20ca52a93e848221cc354d3b0dda
|
|
| MD5 |
508609997e919fee8c9b28ea436a21a2
|
|
| BLAKE2b-256 |
db031913255c1de82ae7395b7cd6519075d4c0e3c313ae649a161630779d8b20
|
Provenance
The following attestation bundles were made for pycustodian-0.0.2.tar.gz:
Publisher:
publish.yml on optophi/pycustodian
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pycustodian-0.0.2.tar.gz -
Subject digest:
06ced650a855d6e7e38f2bfb024ed20cfaec20ca52a93e848221cc354d3b0dda - Sigstore transparency entry: 1807112165
- Sigstore integration time:
-
Permalink:
optophi/pycustodian@a9ac59a76a540b4551c8a0ccdce114fe7972cc5c -
Branch / Tag:
refs/tags/v0.0.2 - Owner: https://github.com/optophi
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a9ac59a76a540b4551c8a0ccdce114fe7972cc5c -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba9dc581e36b64f4a22a8bb47002a8f580368d28188ba8009199e1a7ca4594ec
|
|
| MD5 |
57b53d4330e9a6324c6611470a07f028
|
|
| BLAKE2b-256 |
5a474e5ccc0ceb61b61310aed356fce63b2b9ee7e2f42839da2fbc0afbef655c
|
Provenance
The following attestation bundles were made for pycustodian-0.0.2-py3-none-any.whl:
Publisher:
publish.yml on optophi/pycustodian
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pycustodian-0.0.2-py3-none-any.whl -
Subject digest:
ba9dc581e36b64f4a22a8bb47002a8f580368d28188ba8009199e1a7ca4594ec - Sigstore transparency entry: 1807112218
- Sigstore integration time:
-
Permalink:
optophi/pycustodian@a9ac59a76a540b4551c8a0ccdce114fe7972cc5c -
Branch / Tag:
refs/tags/v0.0.2 - Owner: https://github.com/optophi
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a9ac59a76a540b4551c8a0ccdce114fe7972cc5c -
Trigger Event:
push
-
Statement type: