Inventory Management
Core Concepts
Position Types
# Simple Position (No Cost)
Assets:Bank:Checking 100.00 USD
# Position with Cost Basis
Assets:Invest:VTSAX 10 VTSAX {100.00 USD, "lot-1"}
Inventory Operations
- Augmentations (Adding to inventory):
2024-01-15 * "Buy shares"
Assets:Invest:STOCK 50 STOCK {25.00 USD, "lot-1"}
Assets:Bank:Checking -1250.00 USD
- Reductions (Removing from inventory):
2024-01-20 * "Sell shares"
Assets:Invest:STOCK -25 STOCK {25.00 USD}
Assets:Bank:Checking 625.00 USD
Booking Methods
1. STRICT (Default)
2024-01-01 open Assets:Invest:STOCK "STRICT"
- Requires exact lot match
- Errors on ambiguous matches
- Exception: Total matches allowed
2. FIFO
2024-01-01 open Assets:Invest:STOCK "FIFO"
- Selects oldest matching lots
- Automatically resolves ambiguity
- Matches chronologically
3. LIFO
2024-01-01 open Assets:Invest:STOCK "LIFO"
- Selects newest matching lots
- Reverse chronological order
- Best for tax optimization
4. NONE
2024-01-01 open Assets:Invest:STOCK "NONE"
- No lot matching
- Allows mixed signs
- Similar to Ledger's behavior
Lot Specification
Full Specification
Assets:Invest:STOCK 10 STOCK {
100.00 USD, # Cost basis
2024-01-15, # Acquisition date
"lot-identifier" # Label
}
Matching Methods
# Match by cost
Assets:Invest:STOCK -5 STOCK {100.00 USD}
# Match by date
Assets:Invest:STOCK -5 STOCK {2024-01-15}
# Match by label
Assets:Invest:STOCK -5 STOCK {"lot-identifier"}
# Match any lot
Assets:Invest:STOCK -5 STOCK {}
Price Handling
Price vs Cost
# Price annotation (conversion)
Assets:Forex 1000 USD @ 0.85 EUR
# Cost basis (acquisition)
Assets:Invest 10 STOCK {100.00 USD}
# Both (sale with price record)
Assets:Invest -10 STOCK {100.00 USD} @ 105.00 USD
Price Usage Rules
- Price annotations don't affect booking
- Used only for:
- Currency conversions
- Market value recording
- Capital gains calculations
Configuration
Global Booking Method
option "booking_method" "STRICT"
Per-Account Override
2024-01-01 open Assets:Retirement:401K "FIFO"
2024-01-01 open Assets:Taxable:Stock "STRICT"
Best Practices
- Inventory Organization
# Separate accounts by commodity
Assets:Invest:VTSAX # Only VTSAX
Assets:Invest:VFIAX # Only VFIAX
- Lot Management
# Use meaningful lot labels
Assets:Invest:STOCK 10 STOCK {100.00 USD, "tax-loss-harvest-2024"}
# Document trades
Assets:Invest:STOCK -10 STOCK {100.00 USD} @ 110.00 USD ; Gain: 10%
- Debugging
# Examine inventory state
bean-doctor context ledger.beancount LINENO
# Verify lot matching
bean-check ledger.beancount
This guide provides a comprehensive overview of Beancount's inventory system while maintaining technical accuracy and avoiding any personal opinions.