rustledger
A pure Rust implementation of Beancount, the double-entry bookkeeping language.
Features
- Pure Rust - No Python dependencies, compiles to native and WebAssembly
- Full Beancount Syntax - Parses all directive types with error recovery
- Drop-in Replacement - Compatible CLI commands for Python beancount users
- 7 Booking Methods - STRICT, FIFO, LIFO, HIFO, AVERAGE, and more
- 14 Built-in Plugins - implicit_prices, auto_accounts, pedantic, etc.
- BQL Query Engine - SQL-like queries on your ledger
- Fast - 10x faster than Python beancount
Installation
CLI Tools
# Install with bean-* compatibility aliases (default)
# Install only rledger-* commands (no bean-* aliases)
As a Library
CLI Usage
# Validate a ledger file
# Format a ledger file
# Run a BQL query (one-shot or interactive)
# Generate reports
# Debugging tools
# Use plugins
Python Beancount Compatibility
For users migrating from Python beancount, the bean-* commands are also available:
Library Usage
use load;
Crates
| Crate | Description |
|---|---|
rustledger-core |
Core types: Amount, Position, Inventory, Directives |
rustledger-parser |
Lexer and parser with error recovery |
rustledger-loader |
File loading, includes, options |
rustledger-booking |
Interpolation and booking engine |
rustledger-validate |
30 validation error codes |
rustledger-query |
BQL query engine |
rustledger-plugin |
Native and WASM plugin system |
rustledger |
Command-line tools |
rustledger-wasm |
WebAssembly library target |
Supported Features
Parser
- All 12 directive types (transaction, balance, open, close, etc.)
- Cost specifications:
{100 USD},{{100 USD}},{100 # 5 USD},{*} - Price annotations:
@ 100 USD,@@ 1000 USD - Arithmetic expressions:
(40.00/3 + 5) USD - Multi-line strings:
"""...""" - All transaction flags:
* ! P S T C U R M - Metadata with 6 value types
- Error recovery (continues parsing after errors)
Booking Methods
STRICT- Lots must match exactly (with total match exception)STRICT_WITH_SIZE- Exact-size matches accept oldest lotFIFO- First in, first outLIFO- Last in, first outHIFO- Highest cost firstAVERAGE- Average cost basisNONE- No cost tracking
Built-in Plugins
| Plugin | Description |
|---|---|
implicit_prices |
Generate price entries from costs |
check_commodity |
Validate commodity declarations |
auto_accounts |
Auto-generate Open directives |
leafonly |
Error on non-leaf postings |
noduplicates |
Hash-based duplicate detection |
onecommodity |
Single commodity per account |
unique_prices |
One price per day per pair |
check_closing |
Zero balance assertion on closing |
close_tree |
Close descendant accounts |
coherent_cost |
Enforce cost OR price consistency |
sellgains |
Cross-check gains against sales |
pedantic |
Enable all strict validations |
unrealized |
Calculate unrealized gains |
Options (28 supported)
- Account prefixes (
name_assets,name_liabilities, etc.) - Equity accounts (
account_previous_balances, etc.) - Tolerance settings (
inferred_tolerance_defaultwith wildcards) - Booking method, documents directories, and more
Compatibility
rustledger is compatible with Python beancount. It can parse and validate any valid beancount file. The bean-* command aliases are included by default for easy migration.
Performance
Benchmarks show rustledger is approximately 10x faster than Python beancount for parsing and validation.
License
This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.