fzf + ledger CLI: interactive balance sheet forecasting

by ppn
macOS ◆ xterm-256color ◆ bash 2172 views

Leveraging fzf, dateseq, and ledger CLI to create an easy to navigate balance sheet simulation. In this example, it compares the impact on assets of buying a car vs renting a car. But you could use it for any kind of financial decision.

Using the arrow keys, you navigate from month to month. It gives you an idea of what your balance sheet would look like for any alternative that you’re considering.

Shell:

dateseq 2020-07 2025-01 --format %Y-%m | \
fzf --reverse --preview-window 90% --preview \
  'ledger -f auto_simulatie.ldg bal --forecast "d<[2025]" buy rent --no-total --end {}'

Journal file:

commodity R$
    note Brazilian Real
    format R$ 1.000,00
    nomarket
    alias BRL
    default

define car_price=R$ 60.300,00
define dealership_commission=0.03
define depreciation_yearly=0.06
define insurance_yearly=R$ 3.184,54
define maintenance_yearly=R$ 2.000
define opening_balance=R$ 100.000
define rental_price=R$ 2.000
define taxes_yearly=R$ 2.490
define transfer_fee=R$ 1.350

2020-06-30 Opening Balances
    Buy:Assets:Cash                      (opening_balance)
    Rent:Assets:Cash                     (opening_balance)
    Equity:Opening Balances

2020-07-01 Dealership
    Buy:Assets:Cash                      (-car_price - transfer_fee)
    Buy:Assets:Car                        (car_price * (1 - dealership_commission))
    Buy:Expenses:One-off:Transfer Fee             (transfer_fee)
    Buy:Expenses:One-off:Dealership Commission    (car_price * dealership_commission)

;; Buy
~ Monthly
    Buy:Assets:Car                (-car_price * (depreciation_yearly / 12))
    Buy:Expenses:Depreciation      (car_price * (depreciation_yearly / 12))
    Buy:Expenses:Taxes             (taxes_yearly / 12)
    Buy:Expenses:Insurance         (insurance_yearly / 12)
    Buy:Expenses:Maintenance       (maintenance_yearly / 12)
    Buy:Assets:Cash

;; Rent
~ Monthly
    Rent:Expenses:Car Rental              (rental_price)
    Rent:Assets:Cash                     (-rental_price)