Skip to main content

a-ledger

a-ledger is an application-neutral, SQLite-backed double-entry ledger SDK. It owns accounting primitives and persistence; calling applications own business commands, broker integration, market calendars, projections, APIs, and pages.

Accounting convention

  • Money is stored as integer minor units; posted amounts never use float.
  • A positive posting is a debit and a negative posting is a credit.
  • Every posted transaction balances exactly to zero.
  • Accounts use one of ASSET, LIABILITY, EQUITY, INCOME, or EXPENSE.
  • Security quantities and cost lots are replayed from immutable lot events. There are no persisted balance or position snapshots.
  • Posted transactions, postings, lots, lot events, and audit events cannot be updated or deleted. Corrections use linked reversal and replacement entries.
  • Reservations are mutable authorization state, not accounting entries.

Transaction ownership

The caller supplies a sqlite3.Connection, enables a short transaction, and decides whether to commit or roll back. Write APIs reject calls without an active caller-owned transaction. The SDK never calls commit() or rollback() and never runs network or application callbacks.

import sqlite3

from a_ledger import AccountCategory, Ledger, PostingDraft, TransactionDraft

connection = sqlite3.connect("application.sqlite3")
ledger = Ledger(connection)  # enables and verifies SQLite foreign keys

connection.execute("BEGIN IMMEDIATE")
ledger.install_schema()
ledger.create_portfolio("portfolio-uuid", code="main", currency="CNY")
ledger.create_account(
    "cash-account-uuid",
    portfolio_id="portfolio-uuid",
    code="ASSET:CASH",
    category=AccountCategory.ASSET,
    currency="CNY",
)
ledger.create_account(
    "capital-account-uuid",
    portfolio_id="portfolio-uuid",
    code="EQUITY:CONTRIBUTED_CAPITAL",
    category=AccountCategory.EQUITY,
    currency="CNY",
)
ledger.post(
    TransactionDraft(
        portfolio_id="portfolio-uuid",
        source_namespace="app.capital",
        idempotency_key="capital-flow-uuid",
        event_code="CAPITAL_FLOW",
        business_date="2026-08-03",
        currency="CNY",
        postings=(
            PostingDraft("cash-account-uuid", 100_00),
            PostingDraft("capital-account-uuid", -100_00),
        ),
    )
)
connection.commit()

Non-goals

The package does not define trading strategies, orders, options, QMT behavior, HTTP APIs, UI, market prices, settlement calendars, or bank/broker transfers. Generic event_code, source_type, and JSON dimensions let each application attach its own domain semantics without coupling those semantics to the SDK.

Release files for a-ledger 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for a-ledger 0.1.0
File Size Uploaded
a_ledger-0.1.0.tar.gz 17.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for a-ledger 0.1.0
File Interpreter ABI Platform
a_ledger-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 30.5 kB

Release files / a_ledger-0.1.0.tar.gz

Download URL a_ledger-0.1.0.tar.gz
Size 17.0 kB
Tags Source
SHA-256 checksum
How to use checksums
44c011280aa7200c4dfacf4148f5508d2a6e5d0798ec1997444219e43162f195
BLAKE2b-256 checksum
How to use checksums
6ceee6976ebd963fbeed648a4307b07b70c50e884dbada274a781adcee8d57d9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Aug 7, 2026.

Transparency log

Release files / a_ledger-0.1.0-py3-none-any.whl

Download URL a_ledger-0.1.0-py3-none-any.whl
Size 13.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2ab83e7c5e396df23c9ac5b020a3c8a86a04103f1e8c36696c522f5a1453d520
BLAKE2b-256 checksum
How to use checksums
943d8be8e960e45f817e344c3de5e3aa63d78222916b82511c337c59c6ff0a41
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Aug 7, 2026.

Transparency log

Release history Release notifications | RSS feed

0.3.0

2 release files

0.2.0

2 release files

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page