Double-entry ledger engine for financial transaction processing, multi-currency reconciliation, and treasury cash management — built for fintech systems that move real money.
Written in Python with strict typing and immutable data structures, because financial code that's wrong by a penny is wrong by everything.
fintech-ledger-engine/
├── ledger/
│ ├── __init__.py
│ ├── core.py # Double-entry ledger with ACID guarantees
│ ├── account.py # Chart of accounts and account types
│ ├── transaction.py # Transaction creation, validation, posting
│ ├── reconciliation.py # Multi-source reconciliation engine
│ ├── currency.py # Multi-currency support with FX rates
│ ├── treasury.py # Cash position tracking and forecasting
│ └── audit.py # Immutable audit trail
├── tests/
│ ├── test_ledger.py
│ ├── test_reconciliation.py
│ └── test_treasury.py
├── requirements.txt
└── Makefile
- Every transaction has balanced debits and credits — enforced at the engine level
- Immutable transaction log — posted entries are never modified, only reversed
- Account balance tracking with real-time and point-in-time queries
- Support for accrual and cash-basis accounting
- Transaction amounts stored in original currency and reporting currency
- FX rate snapshots at transaction time for audit trail
- Realized and unrealized gain/loss tracking on currency conversion
- Configurable rounding rules per currency (banker's rounding by default)
- Match transactions across internal ledger, bank feeds, and payment processors
- Configurable matching rules: exact amount, date tolerance, reference matching
- Automatic categorization of breaks: timing, amount, missing, duplicate
- Break resolution workflow with audit trail
- Real-time cash position across all accounts and currencies
- Cash flow forecasting based on scheduled transactions and historical patterns
- Liquidity analysis: available vs. committed vs. reserved
- Sweep rules for automated inter-account transfers
- Hash-chained transaction log for tamper detection
- Every state change recorded with actor, timestamp, and reason
- Exportable for external audit (SOX, SOC 2 aligned)
pip install -r requirements.txt
python -m pytest tests/ -v
# Run the ledger demo
python -m ledger.core- Debits must equal credits — the fundamental invariant, enforced everywhere
- Immutable history — transactions are facts; you correct by reversing, not editing
- Decimal, never float — all monetary values use Python's
Decimaltype - Auditable by default — if money moved, there's a record of why
Built from experience at the US Department of the Treasury, where financial systems operate under regulatory scrutiny that makes SOX look casual. The patterns here — double-entry enforcement, immutable logs, reconciliation engines — are the foundation of every serious fintech system.
MIT