Skip to main content

beancount-lalitm

PyPI

Importers and plugins for Beancount plain-text accounting.

Disclaimer: I am not a tax professional or financial advisor. This code is provided as-is for personal use. The uk_cgt_lots plugin in particular implements my understanding of UK Capital Gains Tax rules, which may be incomplete or incorrect. Use at your own risk.

Installation

pip install beancount-lalitm

# With optional dependencies for specific importers
pip install beancount-lalitm[ib]      # Interactive Brokers (XML)
pip install beancount-lalitm[pdf]     # PDF-based importers
pip install beancount-lalitm[excel]   # Excel-based importers
pip install beancount-lalitm[all]     # All optional dependencies

Importers

Investment Accounts (Fully Automated)

Investment importers can run directly via beangulp since no categorization is needed.

Create an import.py:

#!/usr/bin/env python3
"""Beancount import configuration for investments."""
import beangulp
from beancount import loader
from beancount_lalitm.importers.account_lookup import AccountOracle
from beancount_lalitm.importers.ib import IbImporter

entries, errors, options = loader.load_file('main.beancount')

ib_oracle = AccountOracle(
    account='Lalit:US:IB:Brokerage',
    entries=entries,
    transfers_account='Assets:Lalit:US:IB:Transfers',
)

CONFIG = [
    IbImporter(account_currency='USD', account_oracle=ib_oracle),
]

if __name__ == '__main__':
    beangulp.Ingest(CONFIG)()

Run directly with beangulp:

python import.py extract ~/Downloads/ib-flex-query.xml >> investments.beancount

Bank Accounts (Semi-Automated)

Bank and credit card importers require categorization. Use beancount-import for a web UI that learns from your previous choices.

#!/usr/bin/env python3
"""Beancount import configuration for banks."""
from beancount_lalitm.importers.hsbc import HsbcImporter
from beancount_lalitm.importers.hsbc_uk_cc import HsbcUkCcImporter

CONFIG = [
    HsbcImporter(account='Assets:Lalit:UK:HSBC:Current'),
    HsbcUkCcImporter(account='Liabilities:Lalit:UK:HSBC:CreditCard'),
]

Run the beancount-import web UI:

python -m beancount_import.webserver \
    --journal journal.beancount \
    --ignored_path ignored.beancount \
    --account_filter '^Assets:Lalit:UK:HSBC'

Available Importers

Investment Platforms

Importer Description Input Format
IbImporter Interactive Brokers Flex Query XML
SchwabEacImporter Schwab Equity Award Center Text (PDF converted)
VanguardImporter Vanguard UK Excel
IgImporter IG Trading Text (PDF converted)
AjTransactionsImporter AJ Bell transactions PDF
AjCashImporter AJ Bell cash history CSV
AvivaPensionImporter Aviva pension Text (PDF converted)

Banks

Importer Description Input Format
HsbcImporter HSBC UK current account Text (PDF converted)
HsbcUkCcImporter HSBC UK credit card JSON
HsbcUsCcImporter HSBC US credit card JSON
HsbcUsCheckingImporter HSBC US checking Text (PDF converted)

Payroll

Importer Description Input Format
GooglePayslipImporter Google UK payslips Text (PDF converted)

Plugins

Add plugins to your beancount file with the plugin directive.

ancillary_accounts

Auto-creates companion accounts for investment securities (commissions, dividends, capital gains, withholding tax).

plugin "beancount_lalitm.plugins.ancillary_accounts"

2024-01-01 open Assets:Broker:AAPL  AAPL
  ancillary_commission_currency: USD
  ancillary_distribution_currency: USD
  ancillary_capital_gains_currency: USD

stock_split

Adjusts historical transactions for stock splits.

plugin "beancount_lalitm.plugins.stock_split" "
  splits:
    - symbol: GOOG
      date: 2022-07-15
      ratio: 20
"

uk_cgt_lots

UK Capital Gains Tax lot matching using Section 104 pooling.

plugin "beancount_lalitm.plugins.uk_cgt_lots" "
  accounts:
    - name: Person:UK:Broker:GIA
      taxable: true
    - name: Person:UK:Broker:ISA
      taxable: false
"

License

Apache 2.0 - see LICENSE for details.

Release files for beancount-lalitm 0.2.2

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

Source distribution (sdist)

Source distribution for beancount-lalitm 0.2.2
File Size Uploaded
beancount_lalitm-0.2.2.tar.gz 29.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for beancount-lalitm 0.2.2
File Interpreter ABI Platform
beancount_lalitm-0.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 67.8 kB

Release files / beancount_lalitm-0.2.2.tar.gz

Download URL beancount_lalitm-0.2.2.tar.gz
Size 29.7 kB
Tags Source
SHA-256 checksum
How to use checksums
d268d6d5eaadc6d2575c2354f3221d128f2c76a52db1243a6a3ff63177aa01df
BLAKE2b-256 checksum
How to use checksums
0ca9938607e6e6c271fb616392e0db218b3b2f797070795deba21d2740550e66
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 Jan 1, 2026.

Transparency log

Release files / beancount_lalitm-0.2.2-py3-none-any.whl

Download URL beancount_lalitm-0.2.2-py3-none-any.whl
Size 38.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5efa0463b30da7891c04e3f61717d57f958a968f9e7735207d3db8d84f5a6518
BLAKE2b-256 checksum
How to use checksums
5dce77beb8f92f51209304999e3b47485af69828ba8f96ca5fcf700682ce397f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 Jan 1, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 release files

0.2.0

2 release files

0.1.0

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